hwk3 - remaining elements. (a) Write down the recursive...

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

View Full Document Right Arrow Icon
Fall 2011 CMSC 351: Homework 3 Clyde Kruskal Due at the start of class Wednesday, September 28, 2011. Problem 1. (a) Use the iteration method to solve the following recurrence exactly: T ( n ) = 5 T ( n/ 2) + 2 n - 1 where T (1) = 7. Assume n is a power of 2. (b) Justify your answer using mathematical induction. (c) Solve the same recurrence using the “Master Theorem”. Problem 2. (a) Use the iteration method to solve the following recurrence exactly: T ( n ) = T ( n - 1) + 2 n - 1 where n is a natural number and T (1) = 1. (b) Justify your answer using mathematical induction. (c) State in English what you have proved. Make your statement as short, clean, clear, and accurate as possible. Problem 3. Bubble Sort can be thought of as a recursive algorithm as follows: Bubble the largest element to the bottom of the list (to be sorted). Recursively sort the
Background image of page 1

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

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

Unformatted text preview: remaining elements. (a) Write down the recursive version of Bubble Sort in psuedocode. (b) Derive a recurrence for the exact number of comparisons the algorithm uses. (c) Solve the recurrence (any way you like). Simplify as much as possible. “Master Theorem”: T ( n ) = b aT ( n/b ) + cn d n > 1 f n = 1 implies T ( n ) = p f + c ab-d-1 P n log b a-cn d ab-d-1 = b Θ( n log b a ) a > b d Θ( n d ) a < b d n d ( f + c log b n ) = Θ( n d log b n ) a = b d . Summing solutions: If T ( n ) = b aT ( n/b ) + ∑ c i n d i n > 1 f n = 1 then we can just sum the solutions of each recurrence: T i ( n ) = b aT i ( n/b ) + c i n d i n > 1 n = 1 and add in fn log b a for the contribution from the leaves. 2...
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 351 taught by Professor Staff during the Fall '11 term at University of Louisville.

Page1 / 2

hwk3 - remaining elements. (a) Write down the recursive...

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