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
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 abd1 P n log b acn d abd1 = 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.
 Fall '11
 Staff

Click to edit the document details