hw8-solutions

# hw8-solutions - CS 173 Discrete Structures Fall 2009...

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

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.

Unformatted text preview: CS 173: Discrete Structures, Fall 2009 Homework 8 Solutions This homework contains 3 problems worth a total of 30 regular points. 1. More on recurrences [10 points] In the discussion of Karatsuba’s algorithm for multiplying integers (end of lecture 25), I left out some details of the analysis. Let’s fill in some of them: (a) I claimed that if T has the following recurrence (where c and d are constants) T (1) = c T ( n ) = 4 T ( n/ 2) + dn then T is O ( n 2 ). Show that this is true by unrolling the recurrence, assuming that n is a power of two. (b) I claimed that n ( 3 2 ) log 2 n is O ( n log 2 3 ). Show that this is correct. Hint: use algebra and standard properties of logs and exponentials. Solution: (a) Lets assume n = 2 k . T ( n ) = T (2 k ) = 4 T (2 k / 2) + dn = 4(4 T (2 k / 2 2 ) + d (2 k / 2)) + dn = 4 2 T (2 k / 2 2 ) + 2 d 2 k + d 2 k = 4 2 (4 T (2 k / 2 3 ) + d 2 k / 2 2 ) + 2 d 2 k + d 2 k = 4 3 T (2 k / 2 3 ) + 2 2 d 2 k + 2 d 2 k + d 2 k = . . . = 4 k T (2 k / 2 k ) + 2 k- 1 d 2 k + 2 k- 2 d 2 k + · · · + d 2 k = 4 k T (1) + d 2 k (2 k- 1 + 2 k- 2 + · · · + 1) = 4 k c + d 2 k (2 k − 1) = (2 k ) 2 c + d 2 k (2 k − 1) = cn 2 + dn 2 − dn = O ( n 2 ) (b) n ( 3 2 ) log 2 n =...
View Full Document

### Page1 / 4

hw8-solutions - CS 173 Discrete Structures Fall 2009...

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

View Full Document
Ask a homework question - tutors are online