Lecture11 - 2 n for n >= 2 Induction: Base Case:...

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

View Full Document Right Arrow Icon
CSE 421 Algorithms Richard Anderson Lecture 11 Recurrences
Background image of page 1

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

View Full DocumentRight Arrow Icon
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)
Background image of page 2
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); }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Algorithm Analysis Cost of Merge Cost of Mergesort
Background image of page 4
T(n) <= 2T(n/2) + cn; T(2) <= c;
Background image of page 5

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

View Full DocumentRight Arrow Icon
Recurrence Analysis Solution methods Unrolling recurrence Guess and verify Plugging in to a “Master Theorem”
Background image of page 6
Unrolling the recurrence
Background image of page 7

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

View Full DocumentRight Arrow Icon
Substitution Prove T(n) <= cn log
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13

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

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15

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

View Full DocumentRight Arrow Icon
Background image of page 16
Background image of page 17
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 Right Arrow Icon
Ask a homework question - tutors are online