COMS 482: unofficial class blog


Lecture 11: Recurrences

Posted in Class Notes by Elliott Back on February 16th, 2005. [Del.icio.us]

Some simple recurrences:

  • T(n) <= 2*T(n/2) + cn. This is O(n log n), because it forms a call tree log n levels high with cn work per level.
  • T(n) <= a*T(n/2) + cn. This runs in alog n/2log n*cn, because there are a copies on the first level, a2 on the second, etc, for a total of log n levels. This is a generic recurrence you will see solved for various a.

Another technique for working with recurrences is called “summing over all levels of recursion.” Imagine a recurrence with log n levels of work, and a/2 work performed:

  • T(n) <= Sum((a/2)i) from i = 0 to log n. Using the fact that this represents a geometric sequence, we can simplify this to T(n) <= cn*(1-(a/2)1+log n)/(1 - (a/2)).

We’ve covered the a=2 case already (n log n), so lets look at cases where a > 2 and a < 2:

  • a < 2 –> T(n) <= cn*(1-(a/2)1+log n)/(1 - (a/2)) <= cn * 1/(1-a/2) = O(n)
  • a > 2 –> T(n) <= cn*(1-(a/2)1+log n)/(1 - (a/2)) <= cn*((a/2)1+log n -1)/(a/2-1) = O(n*(a/2)log n = O(alog n) = O(2log alog n) = O(nlog a).

We also had some discussion of the “master theorem” for describing generic recurrences, but didn’t explain it in class.

Finding Closest Pair of Points:

The basic idea? Divide, find closest pair of points, and then merge:

Cloesest Points

We have to check pairs across the dividing line, or which there are O(n2). Let d be the min(closest point on left, closest point on right). Where can we find points on the right that might be closer than d from a point on the left? It turns out you can fit at most 4 points on a circle that satisfy this bound. But, to make the recurrences easier, we will look at a rectangle 2d tall and d wide, on which we can fit at most 6 points. So, sort the points in the y-band by y-coordinate, and compare the left and right sides 6 at a time.

T(n) <= 2*T(n/2) + 4*n*log*n <= 2*T(n/2) + c*n*log*n = O(n log2 n)

If we sort by y coordinate first, and keep the points sorted, we can eliminate the extra n log n times, and get O(n log n) instead!

This entry was posted on Wednesday, February 16th, 2005 at 11:01 pm and is tagged with , , , , , , , , , , , , , . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

Leave a Reply

Your blog, no spam: the ample Wordpress Anti-Spam Plugin.

Please take time to enjoy the archives: May 2005 (1) April 2005 (11) March 2005 (11) February 2005 (15) January 2005 (7)

Fresh, related resources:

Supplied by Google Blog Search
  • MIT?s Introduction to Algorithms: Lectures 1 and 2
    The second half of the lecture is devoted to solving recurrence equations. Three methods are presented:. Substitution method,; Recursion-tree method, and; The Master method. Here is the whole lecture: ...
  • MIT?s Introduction to Algorithms: Lectures 1 and 2
    [01:13:15] Recursion tree solution of the Merge sort?s recurrence equation. Lecture 1 notes:. MIT Algorithms Lecture 1 Notes Thumbnail. Page 1 of 2. Lecture 1, page 1 of 2. MIT Algorithms Lecture 1 Notes Thumbnail. Page 2 of 2. ...
  • Martin Heidegger, 11
    The will becomes free from what is revolting in the 'it was' when it wills the constant recurrence of every 'it was.' The will is delivered from revulsion when it wills the constant recurrencee of the same. ...
  • Whittier Earthquake Shakes LA Basin
    The recurrence intervals suggested by Shaw and Shearer for the Puente Hills Thrust of 250 to 2000 years are short enough to make the fault a significant risk. However, these estimates are based on fault slip rates that are inferred from ...