22.01.2015 Views

Refined Buneman Trees

Refined Buneman Trees

Refined Buneman Trees

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.

is O(n 2 ). The algorithm uses a divide-and-conquer strategy, where the idea<br />

is to cut away search space to quickly find the element we are looking for. If<br />

we were to divide in half every time we would expect to spend linear time<br />

dividing and searching recursively (n + n/2 +n/4 +···+1). However, since<br />

we are partitioning around some element in an array, we are not guaranteed to<br />

partition in the middle each time. The randomized part of the algorithm tries<br />

to remedy this, and the expectation is that selecting an element at random will<br />

on average partition the search space in half. Of course, if we are very unlucky<br />

we will partition such that we only cut away one element each time, for a worst<br />

case performance of O(n 2 ).<br />

10.2 Performance of the selection algorithm<br />

The selection algorithm runs in expected linear time, but worst case quadratic<br />

time. The following test shows that the performance is indeed linear, as expected.<br />

The test was done by running the randomized selection algorithm 50<br />

times on input sizes starting at 10000 and increasing the size by 1000 for each<br />

new run. Each runs consists of 100 repetitions. A plot is made of input size in<br />

number of elements, against running time in milliseconds. This plot is shown in<br />

Figure 10.1. The plot clearly shows that the selection algorithm does indeed run<br />

in linear time, as expected. If one is not satisfied with this algorithm, [CLR90]<br />

has a more complicated selection algorithm which runs in guaranteed worst case<br />

linear time.<br />

66

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

Saved successfully!

Ooh no, something went wrong!