<?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="Insertion sort - Page 20 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=insertion_sort&amp;p=19">1.Previous</a><br />
<a accesskey="3" href="page.php?w=insertion_sort&amp;p=21">3.Next</a>
</p>
<p>k-th element; when this is frequently true (such as if the input array is already sorted or partly sorted), insertion sort is distinctly more efficient compared to selection sort. On average (assuming the rank of the (''k'' + 1)-st element rank is random), insertion sort will require comparing and shifting half of the previous k elements, meaning that insertion sort will perform about half as many comparisons as selection sort on average.</p>

<p>In the worst case for insertion sort (when the input array is reverse-sorted), insertion sort performs</p><p>
<a accesskey="1" href="page.php?w=insertion_sort&amp;p=19">1.Previous</a><br />
<a accesskey="3" href="page.php?w=insertion_sort&amp;p=21">3.Next</a>
</p>

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

</card>
</wml>
