










































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Here you will find the basics of data structures and algorithem
Typology: Lecture notes
Uploaded on 08/09/2020
1 document
1 / 50
This page cannot be seen from the preview
Don't miss anything!
The theoretical study of computer-program
performance and resource usage.
What’s more important than performance?
Input: sequence a 1 , a 2 , …, an of numbers.
Example: Input: 8 2 4 9 3 6
Output: 2 3 4 6 8 9
Output: permutation a' 1 , a' 2 , … , a'n such
that a' 1 a' 2 …^ a'n.
INSERTION-SORT ( A , n ) ⊳ A [1.. n ] for j ← 1 to n do key ← A [ j ] i ← j – 1 while i > 0 and A [ i ] > key do A [ i+ 1] ← A [ i ] i ← i – 1 A [ i+ 1] = key
“pseudocode”
i j
key sorted
2 3 4 6 8 9 done
What is insertion sort’s worst-case time?
BIG IDEA:
“Asymptotic Analysis”
Math: Q( g ( n )) = { f ( n ) : there exist positive constants c 1 , c 2 , and
n 0 such that 0 c 1 g ( n ) f ( n ) c 2 g ( n ) for all n n 0 }
Engineering: