CS 312: Algorithm Analysis Lecture #8: Non-Homogeneous Recurrence Relations This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative Commons Attribution-Share Alike 3.0 Unported License Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, Sean Warnick
Announcements HW #5: due now Start Project #2! Budget enough time Be sure to keep up in the required reading listed on the schedule in Learning Suite
Convex Hull (Proj. #2)
Convexity
Objectives Big Picture: Develop a method to analyze recursive divide and conquer algorithms Work up to a proof of the Master Theorem Find specific solutions using initial conditions Understand how to solve non-homogeneous, linear, recurrence relations with constant coefficients Having geometric forcing functions
Example (cont.): Linear, Homogeneous Recurrence Relation
General Solution: Linear Combinations
Starting things off
Finding the Specific Solution
Specific Solution: One point
Fibonacci in Closed Form!
Fundamental Theorem of Algebra For every polynomial of degree n, there are exactly n roots. They may not be unique.
Roots of Multiplicity j
Example
CS 312: Algorithm Analysis Remainder of Lecture #8: Non-homogeneous Linear Recurrence Relations
Non-Homogeneous, Linear Recurrence Relations
Non-Homogeneous Example What do you notice about the problem now?
Non-Homogeneous Example What do you notice about the problem now?
Example (Cont.)
Coincidence?
Possible Update Point out existence of homog. RR for every non-homog. RR. Notation: Use y(k) (homog.) instead of z(k) (non-homog.) to emphasize the difference.
Initial Conditions
Example (cont.)
Towers of Hanoi Revisited Exercise on HW #6
Assignment Read: Recurrence Relations Notes HW #6: Part II Exercises (Section 2.2) Towers of Hanoi using method of recurrence relations.
Extra Slides
Possible DC Solution: Step 1 Given set of n points Divide into two subsets L containing the leftmost points R containing the rightmost points All points with same x coordinate Assign to the same subset Even if this makes the division not exactly into halves
Possible DC Solution: Step 2 Compute the convex hulls of L and R recursively
Possible DC Solution: Step 3 Combine the left hull CH(L) and the right hull CH(R): Find the two edges known as the upper and lower common tangents (shown in red) Common tangent: a line segment in the exterior of both polygons intersecting each polygon at a single vertex or a single edge. The line containing the common tangent does not intersect the interior of either polygon
Possible DC Solution: Tips Find the upper common tangent: Scan around the left hull in a clockwise direction and around the right hull in a counter-clockwise direction Come up with the details of finding the common tangents – hints available in the guidelines document The tangents divide each hull into two pieces Delete the right edges belonging to the left hull and the left edges belonging to the right hull