<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Quickselect - Page 4 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=quickselect&amp;p=3">1.Previous</a><br />
<a accesskey="3" href="page.php?w=quickselect&amp;p=5">3.Next</a>
</p>
<p><code>left</code> to <code>right</code>) into two parts: those less than a certain element, and those greater than or equal to the element. Here is pseudocode that performs a partition about the element <code>list[pivotIndex]</code>:</p>

<p> <b>function</b> partition(list, left, right, pivotIndex) <b>is</b>     pivotValue := list[pivotIndex]     swap list[pivotIndex] and list[right]  // Move pivot to end     storeIndex := left     <b>for</b> i <b>from</b> left <b>to</b> right - 1 <b>do</b>         <b>if</b> list[i] <= pivotValue <b>then             swap list[storeIndex] and list[i]             increment storeIndex     swap list[right] and list[storeIndex]  // Move pivot to its final place     <b>return</b> storeIndex</=></p><p>
<a accesskey="1" href="page.php?w=quickselect&amp;p=3">1.Previous</a><br />
<a accesskey="3" href="page.php?w=quickselect&amp;p=5">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
