[Home]
[Chapter]
[Contents]
[Previous Algorithm]
[Next Algorithm]


Linear insertion sort with sentinel


procedure sort( var r : ArrayToSort; lo, up : integer ); var i, j : integer; tempr : ArrayEntry; begin r[up+1].k := MaximumKey; for i:=up-1 downto lo do begin tempr := r[i]; j := i+1; while tempr.k > r[j].k do begin r[j-1] := r[j]; j := j+1 end; r[j-1] := tempr end end;

C source (412b.sort.c) Pascal source (412b.sort.p)



© Addison-Wesley Publishing Co. Inc.