11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

86 Chap. 3 <strong>Algorithm</strong> <strong>Analysis</strong>(a) c 1 n(b) c 2 n 3 + c 3(c) c 4 n log n + c 5 n(d) c 6 2 n + c 7 n 63.9 (a) Wh<strong>at</strong> is the smallest integer k such th<strong>at</strong> √ n = O(n k )?(b) Wh<strong>at</strong> is the smallest integer k such th<strong>at</strong> n log n = O(n k )?3.10 (a) Is 2n = Θ(3n)? Explain why or why not.(b) Is 2 n = Θ(3 n )? Explain why or why not.3.11 For each of the following pairs of functions, either f(n) is in O(g(n)), f(n)is in Ω(g(n)), or f(n) = Θ(g(n)). For each pair, determine which rel<strong>at</strong>ionshipis correct. Justify your answer, using the method of limits discussed inSection 3.4.5.(a) f(n) = log n 2 ; g(n) = log n + 5.(b) f(n) = √ n; g(n) = log n 2 .(c) f(n) = log 2 n; g(n) = log n.(d) f(n) = n; g(n) = log 2 n.(e) f(n) = n log n + n; g(n) = log n.(f) f(n) = log n 2 ; g(n) = (log n) 2 .(g) f(n) = 10; g(n) = log 10.(h) f(n) = 2 n ; g(n) = 10n 2 .(i) f(n) = 2 n ; g(n) = n log n.(j) f(n) = 2 n ; g(n) = 3 n .(k) f(n) = 2 n ; g(n) = n n .3.12 Determine Θ for the following code fragments in the average case. Assumeth<strong>at</strong> all variables are of type int.(a) a = b + c;d = a + e;(b) sum = 0;for (i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!