2c03-review - 00027

2c03-review - 00027 - 3 = 6 n n 2 60n 2 . Then, max(6n 3...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS2MD3. Sample solutions to the assignment 1 (many questions have more than one solutions). Total for this assignment is 214 pts. The assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, and resubmit to me during class, office hours, or just slip under the door to my office. 1.[17] Using only definition of O(f(n)) proof that the following statements are true: You should use the following definition: g(n) = O(f(n)) if and only if C>0 n 0 >0 n>n 0 g(n) Cf(n) There are many solutions to the question 1. a.[3] 6n 3 /(log n + 1) = O(n 3 ) Let c=7, n 0 =2. For all n 2, log n 1, and log n +1 2 Then, 6n 3 /(log n +1) 6n 3 /2 = 3n 3 7n 3 hold. b.[3] 23=O(1) Let c=24, n 0 =0. For all n 0, 23 24 × 1 hold. c.[3] max(6n 3 ,10n 2 )=O(n 3 ) Let c=7, n 0 =10. For all n 10, 6n
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 = 6 n n 2 60n 2 . Then, max(6n 3 ,10n 2 ) 6n 3 < 7n 3 hold. d.[5] log n + n 1/2 = O(n 1/2 ). [2] First, we can show (for instance by induction) that, for all m 7, m 2 2 m-1 . [3] Let c=2, n =128 =2 7 , for all n n , 2 m-1 < n 2 m , for some m. And m 7 Therefore, (log n) 2 m 2 2 m-1 < n log n n 1/2 log n + n 1/2 2n 1/2 e.[3] log n + n 1/2 = O(n) Let c=2, n =1. For all n 1, log n n, and n 1/2 n Then, log n + n 1/2 2n hold. 2.[17] Using only definition of O(f(n)) proof that the following statements are false: You should use the following definition: g(n) = O(f(n)) if and only if C>0 n >0 n>n g(n) Cf(n), which means: g(n) O(f(n)) if and only if C>0 n >0 n>n g(n) > Cf(n)...
View Full Document

Ask a homework question - tutors are online