Lecture Notes CMSC 251 Lecture 5 Asymptotics Tuesday Feb 10 1998 Read Chapt 3 in CLR The Limit Rule is not really covered in the text Read Chapt 4 for next time Asymptotics We have introduced the notion of notation and last time we gave a formal definition Today we will explore this and other asymptotic notations in greater depth and hopefully give a better understanding of what they mean Notation Recall the following definition from last time Definition Given any function g n we define g n to be a set of functions g n f n there exist strictly positive constants c1 c2 and n0 such that 0 c1 g n f n c2 g n for all n n0 Let s dissect this definition Intuitively what we want to say with f n g n is that f n and g n are asymptotically equivalent This means that they have essentially the same growth rates for large n For example functions like 4n2 8n2 2n 3 n2 5 n 10 log n and n n 3 are all intuitively asymptotically equivalent since as n becomes large the dominant fastest growing term is some constant times n2 In other words they all grow quadratically in n The portion of the definition that allows us to select c1 and c2 is essentially saying the constants do not matter because you may pick c1 and c2 however you like to satisfy these conditions The portion of the definition that allows us to select n0 is essentially saying we are only interested in large n since you only have to satisfy the condition for all n bigger than n0 and you may make n0 as big a constant as you like An example Consider the function f n 8n2 2n 3 Our informal rule of keeping the largest term and throwing away the constants suggests that f n n2 since f grows quadratically Let s see why the formal definition bears out this informal observation We need to show two things first that f n does grows asymptotically at least as fast as n2 and second that f n grows no faster asymptotically than n2 We ll do both very carefully Lower bound f n grows asymptotically at least as fast as n2 This is established by the portion of the definition that reads paraphrasing there exist positive constants c1 and n0 such that f n c1 n2 for all n n0 Consider the following almost correct reasoning f n 8n2 2n 3 8n2 3 7n2 n2 3 7n2 7n2 Thus if we set c1 7 then we are done But in the above reasoning we have implicitly made the assumptions that 2n 0 and n2 3 0 These are not true for all n but they are true for all sufficiently large n In particular if n 3 then both are true So let us select n0 3 and now we have f n c1 n2 for all n n0 which is what we need Upper bound f n grows asymptotically no faster than n2 This is established by the portion of the definition that reads there exist positive constants c2 and n0 such that f n c2 n2 for all n n0 Consider the following reasoning which is almost correct f n 8n2 2n 3 8n2 2n 8n2 2n2 10n2 This means that if we let c2 10 then we are done We have implicitly made the assumption that 2n 2n2 This is not true for all n but it is true for all n 1 So let us select n0 1 and now we have f n c2 n2 for all n n0 which is what we need 16 Lecture Notes CMSC 251 From the lower bound we have n0 3 and from the upper bound we have n0 1 and so combining be the larger of the two n 3 Thus in conclusion if we let c1 7 c2 10 and these we let n 0 0 n0 3 then we have 0 c1 g n f n c2 g n for all n n0 and this is exactly what the definition requires Since we have shown by construction the existence of constants c1 c2 and n0 we have established that f n n2 Whew That was a lot more work than just the informal notion of throwing away constants and keeping the largest term but it shows how this informal notion is implemented formally in the definition Now let s show why f n is not in some other asymptotic class First let s show that f n n If this were true then we would have to satisfy both the upper and lower bounds It turns out that the lower bound is satisfied because f n grows at least as fast asymptotically as n But the upper bound is false In particular the upper bound requires us to show there exist positive constants c2 and n0 such that f n c2 n for all n n0 Informally we know that as n becomes large enough f n 8n2 2n 3 will eventually exceed c2 n no matter how large we make c2 since f n is growing quadratically and c2 n is only growing linearly To show this formally suppose towards a contradiction that constants c2 and n0 did exist such that 8n2 2n 3 c2 n for all n n0 Since this is true for all sufficiently large n then it must be true in the limit as n tends to infinity If we divide both side by n we have 3 c2 lim 8n 2 n n It is easy to see that in the limit the left side tends to and so no matter how large c2 is this statement is violated This means that f n n Let s show that f n n3 Here the idea will be to violate the lower bound there exist positive constants c1 and n0 such that f n c1 n3 for all n n0 Informally this is true because f n is growing quadratically and eventually any cubic function will exceed it To show this formally suppose towards a contradiction that constants c1 and n0 did exist such that 8n2 2n 3 c1 n3 for all n n0 Since this is true for all sufficiently large n then it must be true in the limit as n tends to infinity If we divide both side by n3 we have 2 3 8 2 3 c1 lim n n n n It is easy to see that in the limit the left side tends to 0 and so the only way to satisfy this requirement n3 is to set c1 0 but by hypothesis c1 is positive This means that f n O notation and notation We have seen that the definition of notation relies on proving both a lower and upper asymptotic bound Sometimes we are only interested in proving one bound or the other The O notation allows us to state asymptotic upper bounds and the notation allows us to state asymptotic lower bounds Definition Given any function g n O g n …
View Full Document