18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lecture 3 - recurrence relations<br />

Polygon Triangulation<br />

Given a polygon in the plane, add diagonals so that each face is a triangle None of the diagonals are<br />

allowed to cross.<br />

Triangulation is an important first step in many geometric algorithms.<br />

<strong>The</strong> simplest algorithm might be to try each pair of points and check if they see each other. If so, add the<br />

diagonal and recur on both halves, for a total of .<br />

However, Chazelle gave an algorithm which runs in time. Since<br />

, by case 1 of the Master <strong>The</strong>orem, Chazelle's algorithm is linear, ie. T(n) = O(n).<br />

Sorting<br />

<strong>The</strong> classic divide and conquer recurrence is Mergesort's T(n) = 2 T(n/2) + O(n), which divides the data<br />

into equal-sized halves and spends linear time merging the halves after they are sorted.<br />

Since but not , Case 2 of the Master <strong>The</strong>orem applies and<br />

.<br />

In case 2, the divide and merge steps balance out perfectly, as we usually hope for from a divide-andconquer<br />

algorithm.<br />

Mergesort Animations<br />

Approaches to <strong>Algorithm</strong>s <strong>Design</strong><br />

Incremental<br />

Job is partly done - do a little more, repeat until done.<br />

file:///E|/LEC/LECTUR17/NODE3.HTM (9 of 10) [19/1/2003 1:34:27]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!