chapter2

# chapter2 - Chapter 2 Solutions 2 2.2 Consider b 2.3 a logb...

This preview shows pages 1–4. Sign up to view the full content.

Chapter 2– Solutions January 31, 2007

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

View Full Document
2 2.2. Consider b d log b n e . 2.3. a) T ( n ) = 3 T ± n 2 ² + cn = ··· = 3 k T ± n 2 k ² + cn k - 1 X i =0 ³ 3 2 ´ i = = 3 k T ± n 2 k ² + 2 cn µ ³ 3 2 ´ k - 1 ! For k = log 2 n , T ( n 2 k ) = T (1) = d = O (1). Then: T ( n ) = dn log 2 3 + 2 cn ³ n log 2 3 n - ´ = Θ( n log 2 3 ) as predicted by the Master theorem. b) T ( n ) = T ( n - 1) + c = ··· = T ( n - k ) + kc . For k = n , T ( n ) = T (0) + nc = Θ( n ). 2.4. a) This is a case of the Master theorem with a = 5 ,b = 2 ,d = 1. As a > b d , the running time is O ( n log b a ) = O ( n log 2 5 ) = O ( n 2 . 33 ). b) T ( n ) = 2 T ( n - 1)+ C , for some constant C . T ( n ) can then be expanded to C n - 1 i =0 2 i +2 n T (0) = O (2 n ). c) This is a case of the Master theorem with a = 9 ,b = 3 ,d = 2. As a = b d , the running time is O ( n d log n ) = O ( n 2 log n ). 2.5. a) T ( n ) = 2 T ( n/ 3) + 1 = Θ( n log 3 2 ) by the Master theorem. b) T ( n ) = 5 T ( n/ 4) + n = Θ( n log 4 5 ) by the Master theorem. c) T ( n ) = 7 T ( n/ 7) + n = Θ( n log 7 n ) by the Master theorem. d) T ( n ) = 9 T ( n/ 3) + n 2 = Θ( n 2 log 3 n ) by the Master theorem. e) T ( n ) = 8 T ( n/ 2) + n 3 = Θ( n 3 log 2 n ) by the Master theorem. f) T ( n ) = 49 T ( n/ 25) + n 3 / 2 log n = Θ( n 3 / 2 log n ). Apply the same reasoning of the proof of the Master Theorem. The contribution of level i of the recursion is ³ 49 25 3 / 2 ´ i n 3 / 2 log ± n 25 3 / 2 ² = ³ 49 125 ´ i O ( n 3 / 2 log n ) Because the corresponding geometric series is dominated by the contribution of the ﬁrst level, we obtain T ( n ) = O ( n 3 / 2 log n ). But, T ( n ) is clearly Ω( n 3 / 2 log n ). Hence, T ( n ) = Θ( n 3 / 2 log n ). g) T ( n ) = T ( n - 1) + 2 = Θ( n ). h) T ( n ) = T ( n - 1) + n c = n i =0 i c + T (0) = Θ( n c +1 ). i) T ( n ) = T ( n - 1) + c n = n i =0 c i + T (0) = c n +1 - 1 c - 1 + T (0) = Θ( c n ). j) T ( n ) = 2 T ( n - 1) + 1 = n - 1 i =0 2 i + 2 n T (0) = Θ(2 n ). k) T ( n ) = T ( n ) + 1 = k i =0 1 + T ( b ), where k Z such that n 1 2 k is a small constant b , i.e. the size of the base case. This implies k = Θ(log log n ) and T ( n ) = Θ(log log n ). 2.6. The corresponding polynomial is 1 t 0 ( 1 + x + x 2 + ··· + x t 0 ) .
3 2.7. For n 6 = 0 and ω = e 2 π n : n - 1 X i =0 ω i = 1 - ω n 1 - ω = 0 n - 1 Y i =0 ω i = ω n - 1 i =0 i = ω n ( n - 1) 2 The latter is 1 if n is odd and - 1 if n is even. 2.8. a) The appropriate value of ω is i . We have FFT(1 , 0 , 0 , 0) = (1 , 1 , 1 , 1) and FFT(1 / 4 , 1 / 4 , 1 / 4 , 1 / 4) = (1 , 0 , 0 , 0). b) FFT(1 , 0 , 1 , - 1) = (1 ,i, 3 , - i ). 2.9. a) Use ω = i . The FFT of x + 1 is FFT(1 , 1 , 0 , 0) = (2 ,i + 1 , 0 ,i - 1). The FFT of x 2 + 1 is FFT(1 , 0 , 1 , 0) = (2 , 0 , 2 , 0). Hence, the FFT of their product is (4 , 0 , 0 , 0), corresponding to the polynomial 1 + x + x 2 + x 3 .

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

chapter2 - Chapter 2 Solutions 2 2.2 Consider b 2.3 a logb...

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

View Full Document
Ask a homework question - tutors are online