algtech - Algorithm Analysis Techniques To review the...

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

View Full Document Right Arrow Icon
Algorithm Analysis Techniques To review the following: Order analysis Summation techniques Recursion Recurrences A running example: Given an array of integers (positive, zero, negative), find a sequence of contiguous locations that result in the largest sum, among all possible such sequences.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Order Notations: Suppose f ( n ) and g ( n ) are two functions defined on integers n 0 and f ( n ) > 0, g ( n ) > 0. Definition of Big-O : We write f ( n ) = O( g ( n )), or, simply f = O( g ), if there exist positive constants c and k (i.e. independent of n ), such that f ( n ) c g ( n ) for all n k . Example: If f ( n ) = 3 n + 12, g ( n ) = n , then f = O( g ) because 3 n + 12 4 n when n 12. (Thus, c = 4 and k = 12.) Definition of Little-o: We write f ( n ) = o( g ( n )), or, simply f = o( g ), if Example: 3 n + 12 = o( n 2 ) because Definition of Theta Θ : We write f ( n ) = Θ ( g ( n )), or, simply f = Θ ( g ), if f = O( g ) and g = O( f ). Example: 3 n + 12 = Θ ( n ). . 0 lim ) ( ) ( = n g n f n . 0 ) 12 3 ( lim 12 3 lim 2 2 = + = + n n n n n n
Background image of page 2
Theorems (facts, rules) about order notations: (1) If and if c 0, then f = Θ ( g ). (2) If then f = O( g ). (That is, little-o implies big-O.) (3) If then g = o( f ). (4) If f 1 = O( g 1 ) and f 2 = O( g 2 ), then f 1 + f 2 = O( g 1 + g 2 ) and f 1 f 2 = O( g 1 g 2 ). (5) f 1 + f 2 = Θ (max( f 1 , f 2 )). (For example, (2 n + 12) + (lg n ) = Θ (2 n + 12) = Θ ( n ). Note: When doesn’t exist (e.g., because the value of the ratio oscillates as n grows), we cannot conclude the relative magnitude between f and g . , ) ( ) ( lim c n g n f n = , 0 ) ( ) ( lim = n g n f n , ) ( ) ( lim = n g n f n ) ( ) ( lim n g n f n
Background image of page 3

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

View Full DocumentRight Arrow Icon
Typical growth rates in increasing order of magnitudes: Function Name c constant lg n logarithmic n linear n lg n n lg n (between linear and quadratic?) n 2 quadratic n 3 cubic 2 n exponential n ! factorial 2 n n ! super-factorial (?)
Background image of page 4
Summation rules and formulas: (1) (2) where k is independent of the summation index i and independent of n . (3)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

algtech - Algorithm Analysis Techniques To review the...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online