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
 Fall '11
 Staff
 Recursion, Natural number, Recurrence relation, following recurrence, ci ndi

Click to edit the document details