{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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”

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

View Full Document
2 Unrolling the recurrence Substitution
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

{[ snackBarMessage ]}