hw1solution

hw1solution - n i =1 ( logi + log 2) = n i =1 log (2 i ) =...

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

View Full Document Right Arrow Icon
CSC 316 Data Structures Homework 1 ANSWERS 1. (10 points) Answer: * c is a real constant such that c > 0 and n 0 is an integer constant such that n 0 1 (a) c = 1, n 0 = 1 (b) c = 1, n 0 = 1 (c) c = 1, n 0 = 1 (d) c 0 = 2, n 0 = 2 n 2 2 * ( n 2 - 1) for n 2 c 00 = 1, n 0 = 1 n 2 1 * ( n 2 - 1) for n 1 (e) c = 1, n 0 = 1 2. (10 points) Answer: (a) False, if f ( n ) = n , g ( n ) = n 2 , then n = O ( n 2 ) but n 2 6 = O ( n ) (b) True. (c) False, if f ( n ) = 1 /n , then 1 /n 6 = O (1 /n 2 ) (d) True. (e) False, if f ( n ) = 4 n , then 4 n 6 = O (2 n ), so f ( n ) 6 = Θ( f ( n/ 2)). 3. (10 points) Answer: From faster to slower (1) 2 10 = O (1) (2) 3 n + 100 logn = O ( n ), 4 n = O ( n ), 2 logn = O ( n ) (3) nlogn = O ( nlogn ), 4 nlogn + 2 n = O ( nlogn ) (4) n 2 + 10 n = O ( n 2 ) (5) n 3 = O ( n 3 ) (6) 2 n = O (2 n ) 4. (10 points) Answer: (1) n 2 (2) N (3) Find2D is a linear-time algorithm since it depends on input size of N 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
5. (5 points) Answer: Since: lim n →∞ n 2 nlogn by using L’ Hopital’s Rule lim n →∞ 2 n ( logn + n * (1 /n )) = Hence: n 2 = Ω( nlogn ) 6. (5 points) Answer: ( n + 1) 5 = n 5 + 5 n 4 + 10 n 3 + 10 n 2 + 5 n + 1 Since n 5 + 5 n 4 + 10 n 3 + 10 n 2 + 5 n + 1 (1 + 5 + 10 + 10 + 5 + 1) n 5 , for n 1 Hence ( n + 1) 5 = O ( n 5 ) . Or Since lim n - >infinite ( n +1) 5 n 5 = 1 Hence: ( n + 1) 5 = Θ( n 5 ) Hence: ( n + 1) 5 = O ( n 5 ) 7. (5 points) Answer: n i =1 d log 2 i e ≤
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n i =1 ( logi + log 2) = n i =1 log (2 i ) = log 2 + log 4 + log 6 + ... + log 2 n nlog (2 n ) = nlog ( n ) + nlog 2 Hence : n i =1 d log 2 i e = O ( nlogn ) d x e give smallest integer larger than or equal to x . So n i =1 d log 2 i e is not always same as n i =1 log 2 i 8. (5 points) Answer: Since: d ( n ) c * f ( n ) for n n , c > 0, n 1 e ( n ) c * g ( n ) for n n , c > 0, n 1 Hence: d ( n ) + e ( n ) c * f ( n ) + c * g ( n ) for n max ( n ,n ) Assume: c 00 = max ( c,c ) ,n 00 = max ( n ,n ) Hence: d ( n ) + e ( n ) c 00 * ( f ( n ) + g ( n )) for n n 00 , c 00 > 0, n 00 1 That is: d ( n ) + e ( n ) = O ( f ( n ) + g ( n )) 2...
View Full Document

This note was uploaded on 03/24/2008 for the course CSC 316 taught by Professor Rhee during the Spring '08 term at N.C. State.

Page1 / 2

hw1solution - n i =1 ( logi + log 2) = n i =1 log (2 i ) =...

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

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