2004_fall_exam1_sol

2004_fall_exam1_sol - P1. Solve the recurrence relation...

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

View Full Document Right Arrow Icon
P1. Solve the recurrence relation without using Master’s theorem: T(N) = 3T(N/2) + cN Ans.: Assume N = 2 k T(2 k ) = 3 T(2 k-1 ) + c 2 k = 3 2 T(2 k-2 ) + c ( 2 k + 3* 2 k-1 ) …. After k steps = 3 k T(1) + c ( 2 k + 3* 2 k-1 + 3 2 * 2 k-2 + … + 3 k-1 * 2) = 3 k d + c 2 k (1 + 3/2 + (3/2) 2 + (3/2) 3 + …. + (3/2) k-1 ) = 3 k d + c N [ (3/2) k –1] / [3/2 –1] = 3 k d + 2c N ( 3 k /N – 1) = 3 k (d + 2c) – 2cN Now, 3 k = (2 log 3 ) k = (2 k ) log 3 = N log 3 = N log 3 (2c + d) – 2cN = Theta (N log 3 ) P2. A and B are playing a guessing game where B first thinks up an integer X (positive, negative or zero, and could be of arbitrarily large magnitude) and A tries to guess it. In response to A ’s guess, B gives exactly one of the following three replies: a) Try a bigger number b) Try a smaller number or c) You got it!! Design an efficient algorithm to minimize the number of guesses A has to make. An example (not necessarily an efficient one) below: B thinks up the number 35 A’s guess B’s response 10 Try a bigger number 20 Try a bigger number 30 Try a bigger number 40 Try a smaller number 35 You got it
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2011 for the course COT 5405 taught by Professor Ungor during the Fall '08 term at University of Florida.

Page1 / 4

2004_fall_exam1_sol - P1. Solve the recurrence relation...

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