This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Introduction to Algorithms September 18, 2006 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Madhu Sudan Problem Set 1 Solutions Problem Set 1 Solutions Problem 11. Asymptotic Notation For each of the following relationships, find two nonnegative functions f ( n ) and g ( n ) that satisfy it. If no such functions exist, write NONE and briefly justify your answer. (a) f ( n ) = O ( g ( n )) and g ( n ) = O ( f ( n )) . Solution: f ( n ) = g ( n ) = n. (b) f ( n ) = o ( g ( n )) and g ( n ) = o ( f ( n )) . Solution: NONE : If f ( n ) = o ( g ( n )) , then there exists an n such that, for all n > n , f ( n ) < 1 2 g ( n ) . Similarly, g ( n ) = o ( f ( n )) implies that there exists an n 1 such that, for all n > n 1 , g ( n ) < 1 2 f ( n ) . Thus, for all n > max { n , n 1 } , we have f ( n ) < 1 4 f ( n ) , which cannot hold if f ( n ) is nonnegative. (c) f ( n ) = ( f ( n )) Solution: NONE : f ( n ) = ( f ( n )) implies that there exists an n such that, for all n > n , f ( n ) > f ( n ) . But this is clearly impossible. (d) f ( n ) = ( g ( n )) and g ( n ) = ( f ( n ) + g ( n )) . Solution: NONE : If we add g ( n ) to both sides of f ( n ) = ( g ( n )) , we obtain that f ( n ) + g ( n ) = ( g ( n )) . Substituting this relation into the righthand side of g ( n ) = ( f ( n ) + g ( n )) , we obtain that g ( n ) = ( g ( n )) , which is impossible by part (c). (e) f ( n ) = (1) and g ( n ) = o ( f ( n )) Solution: f ( n ) = 1 , g ( n ) = 1 /n . (f) f ( n ) = O (1) and g ( n ) = o ( f ( n ) + g ( n )) . Solution: f ( n ) = 1 , g ( n ) = 1 /n . 2 Problem Set 1 Solutions Problem 12. Recurrences Give asymptotic upper and lower bounds for T ( n ) in each of the following recurrences. Assume that T ( n ) is a nonnegative constant for n 10 . Make your bounds as tight as possible, and justify your answers. (a) T ( n ) = 3 T ( n/ 3) + n Solution: Using the notation of the Master Theorem, we have a = 3 , b = 3 , so n log b a = n , and f ( n ) = n . Thus, by Case 2 of the Master Theorem, T ( n ) = ( n lg n ) . (b) T ( n ) = 11 T ( n/ 7) + n 3 Solution: Using the notation of the Master Theorem, we have a = 11 , b = 7 , so n log b a n 1 . 23 , and f ( n ) = n 3 . The regularity condition is easy to verify: af ( n/b ) = 11( n/ 7) 3 = (11 / 343) n 3 1 2 n 3 . Thus, by Case 3 of the Master Theorem, T ( n ) = ( n 3 ) ....
View
Full
Document
This note was uploaded on 01/20/2012 for the course CS 6.006 taught by Professor Erikdemaine during the Fall '08 term at MIT.
 Fall '08
 ErikDemaine
 Algorithms

Click to edit the document details