Refined Buneman Trees
Refined Buneman Trees
Refined Buneman Trees
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Algorithm 9 The RANDOMIZED-PARTITION algorithm<br />
Require: A is an array of length n.<br />
Require: p, r are indices in A<br />
Ensure: returns q such that elements in A[p..q] are all less than or equal to all<br />
elements in A[q +1..r].<br />
1: i = RANDOM(p, r)<br />
2: SWAP(A[p],A[i])<br />
3: return PARTITION(A, p, r)<br />
Algorithm 10 The PARTITION algorithm<br />
Require: A is an array of length n.<br />
Require: p, r are indices in A<br />
Ensure: returns j such that elements in A[p..j − 1] are all less than or equal<br />
to all elements in A[j..r].<br />
1: x = A[p]<br />
2: i = p − 1<br />
3: j = r +1<br />
4: while true do<br />
5: repeat<br />
6: j = j − 1<br />
7: until A[j] ≤ x<br />
8: repeat<br />
9: i = i +1<br />
10: until A[i] ≥ x<br />
11: if i