{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture-8

# lecture-8 - CPSC 223 Algorithms Data Abstract Structures...

This preview shows pages 1–6. Sign up to view the full content.

9/23/10’ 1’ CPSC 223 Algorithms & Data Abstract Structures Lecture 8: Algorithm Analysis and Sorting Today … Homework Homework 3 Due Homework 4 Assigned More on complexity analysis [Sect. 9.1] Binary search Bubble, selection, and insertion sort [Sect. 9.2] Next week: Midterm (Thurs.) CPSC’223’--’Fall’2010’ 2’

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
9/23/10’ 2’ Order-of-Magnitude Analysis Big O notation focuses algorithm growth rates an upper bound (running time will not be worse) independent of the particular implementation or computer used to execute the algorithm Given algorithm A , we say A requires time proportional to a function f ( n ) n is the size of the input we say that “ A is order f ( n )” … which we write as O ( f ( n )) CPSC’223,’2009’ 3’ Order-of-Magnitude Analysis f ( n ) represents the algorithm’s growth rate as a function over input size n Examples: If A requires time directly proportional to n , then f ( n ) = n … which we write O ( n ) If A requires time proportional to n 2 , then f ( n ) = n 2 … which we write O ( n 2 ) CPSC’223,’2009’ 4’
9/23/10’ 3’ Order-of-Magnitude Analysis Notice that we don’t include constant terms e.g., instead of 6 n + 5 , we write O ( n ) … and instead of 6 n 2 + n – 8 , we write O ( n 2 ) We are interested in the algorithm’s general rate of growth This makes it easier to compare different solutions CPSC’223,’2009’ 5’ Order-of-Magnitude Analysis We’re looking at input sizes large enough to make only the growth of the running time relevant We’re studying the “ asymptotic ” efFciency of algorithms We’re concerned with how the running time of an algorithm increases with the size of the input in the limit … as the size of the input increases without bound CPSC’223,’2009’ 6’

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
9/23/10’ 4’ Order-of-Magnitude Analysis Defnition oF the Order oF an Algorithm (textbook): Algorithm A is O ( f ( n )) iF constants k and n 0 exist such that requires no more than k · f ( n ) time units to solve a problem oF size n n 0 Alternative defnition oF big O analysis [Cormen et al.] ±or a given Function g ( n ) , we denote by O ( g ( n )) the set oF Functions O ( g ( n )) = { f ( n ) | there exist positive constants k and n 0 such that 0 f ( n ) k · g ( n ) for all n n 0 } Thus, big O gives an upper bound on a Function f ( n ) to within a constant factor CPSC’223,’2009’ 7’ Growth Rates ±airly typical growth- rate Functions Ordered From least to most expensive CPSC’223,’2009’ 8’ [Carrano,’2007]’
9/23/10’ 5’ Asymptotic Upper Bounds

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 15

lecture-8 - CPSC 223 Algorithms Data Abstract Structures...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online