Mesh Generation

Numerous methods may be used to sort an array containing items on which an ordering is defined.
Sorting by insertion. Let us consider an array of size n and let us assume, at the stage i of the processing, for i = 1, , n ? 1, that the sub-array i (between the indices 1 and i) has already been sorted. The algorithm of sorting by insertion consists of inserting v = Tab( i + 1) in the sub-array i in the right place, by moving the items greater than v towards the right. This can be written as follows:
Sorting by insertion from the smallest to the largest.
<b class="bold">Procedure InsertionSort (Tab)</b> <b class="bold">FOR</b> i = 2, n value <span class="unicode">?</span> Tab(i) j <span class="unicode">?</span> i - 1 <b class="bold">WHILE</b> j > 0 <b class="bold">AND</b> TAB(j) > key TAB(j + 1) <span class="unicode">?</span> TAB(j) j <span class="unicode">?</span> j - 1 <b class="bold">END WHILE</b> TAB(j + 1) <span class="unicode">?</span> value <b class="bold">END FOR</b>
to obtain a sorting algorithm...