Algorithm Analysis (CSC 301 2015F) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Algorist]
Related Courses: [Walker (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Held: Monday, 7 September 2015
Back to Outline 04 - Asymptotic Algorithm Analysis, Continued. On to Outline 06 - Asyptotic Analysis and Recurrence Relations.
Summary
We consider divide-and-conquer algorithms and the techniques we use to analyze such algorithms.
Related Pages
Overview
Administrivia
For example, for merge sort, our recurrence is
T(1) = 1
T(n) = 2*T(n/2) + theta(n)
Why? Because we do two recursive calls on size n/2 and then spend n extra work merging.
Working downward
T(n) <= 2*T(n/2) + cn
<= 2*(2*T(n/4) + c*n/2) + cn
= 4*T(n/4) + 2*n
<= 4(2*T(n/8) + c*n/4) + 2*n
= 8*T(n/8) + 3*n
...
<= (2^k)*T(n/(2^k)) + k*n
Let k = log_2(n)
<= n*T(1) + nlog_2(n).
Working upward
T(2) = 2*T(1) + 2c = 2 + 2c
T(4) = 2*T(2) + 4c = 2*(2+2c) + 4c = 4 + 4c + 4c = 4 + 8c
T(8) = 2*T(4) + 8c = 2*(4+8c) + 8c = 8 + 24c
T(16) = 2*T(8) + 16c = 2*(8+24c) + 16c = 16 + 64c
Pattern: T(n) = n + n*log_2(n)*c
We'll see other techniques