All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----jdsl.core.algo.sorts.ListInsertionSort
The sort proceeds by looking at each element in S, removing it, and inserting it in its place in a sorted sequence on the side.
public ListInsertionSort()
public void sort(Sequence S, Comparator c)
The sort proceeds by looking at each element in S, removing it, and inserting it in its place in a sorted sequence on the side. Once S has been emptied, the temporary sequence is sorted; move all its elements back to S. This sort also demonstrates the use of a sentinel: to avoid unnecessary checks for the end of the temporary sequence, we insert an element as big as the biggest element, guaranteeing that no element will be inserted after it. This element is removed before copying back into S, to avoid changing S's contents.
All Packages Class Hierarchy This Package Previous Next Index