04.09.2013 Views

Algorithm Design

Algorithm Design

Algorithm Design

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

732<br />

Chapter 13 Randomized <strong>Algorithm</strong>s<br />

Put aj in S- if a]ai<br />

Endfor<br />

Recursively call Quicksort(S-) and Quicksort(S+)<br />

Output the sorted set S-, then a t, then the sorted set S +<br />

Endif<br />

As with median-finding, the worst-case running time of this method is<br />

not so good. If we always select the smallest element as a splitter, then the<br />

nmning time T(n) on n-element sets satisfies the same recurrence as before:<br />

T(n)

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

Saved successfully!

Ooh no, something went wrong!