Lecture11 - Substitution Prove T(n) <= cn log 2 n for n...

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

View Full Document Right Arrow Icon
1 CSE 421 Algorithms Richard Anderson Lecture 11 Recurrences Divide and Conquer • Recurrences, Sections 5.1 and 5.2 • Algorithms – Counting Inversions (5.3) – Closest Pair (5.4) – Multiplication (5.5) – FFT (5.6) Divide and Conquer Array Mergesort(Array a){ n = a.Length; if (n <= 1) return a; b = Mergesort(a[0 . . n/2]); c = Mergesort(a[n/2+1 . . n-1]); return Merge(b, c); } Algorithm Analysis • Cost of Merge • Cost of Mergesort T(n) <= 2T(n/2) + cn; T(2) <= c; Recurrence Analysis • Solution methods – Unrolling recurrence – Guess and verify – Plugging in to a “Master Theorem”
Background image of page 1

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

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

Unformatted text preview: Substitution Prove T(n) <= cn log 2 n for n >= 2 Induction: Base Case: Induction Hypothesis: A better mergesort (?) Divide into 3 subarrays and recursively sort Apply 3-way merge What is the recurrence? Unroll recurrence for T(n) = 3T(n/3) + dn T(n) = aT(n/b) + f(n) T(n) = T(n/2) + cn Where does this recurrence arise? 3 Solving the recurrence exactly T(n) = 4T(n/2) + cn T(n) = 2T(n/2) + n 2 T(n) = 2T(n/2) + n 1/2 Recurrences Three basic behaviors Dominated by initial case Dominated by base case All cases equal we care about the depth...
View Full Document

This note was uploaded on 02/25/2012 for the course CSE 421 taught by Professor Richardanderson during the Fall '06 term at University of Washington.

Page1 / 3

Lecture11 - Substitution Prove T(n) <= cn log 2 n for n...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online