# Lecture11 - 2 n for n &amp;amp;gt;= 2 Induction: Base Case:...

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

CSE 421 Algorithms Richard Anderson Lecture 11 Recurrences

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

View Full Document
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); }

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

View Full Document
Algorithm Analysis Cost of Merge Cost of Mergesort
T(n) <= 2T(n/2) + cn; T(2) <= c;

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

View Full Document
Recurrence Analysis Solution methods Unrolling recurrence Guess and verify Plugging in to a “Master Theorem”
Unrolling the recurrence

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

View Full Document
Substitution Prove T(n) <= cn log

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2 n for n &gt;= 2 Induction: Base Case: Induction Hypothesis: T(n/2) &lt;= c(n/2) log 2 (n/2) 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? 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 / 17

Lecture11 - 2 n for n &amp;amp;gt;= 2 Induction: Base Case:...

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

View Full Document
Ask a homework question - tutors are online