display | more...
Example Code:
procedure shell(var a : anarray; N : integer);

 var i, j, h, v : integer;

begin

  h := 1;
  repeat
   h := 3*h + 1
  until h > N;

  repeat
   h := h div 3;
   for i := h+1 to N do
    begin
     v := a[i]
     j := i;
     while (j > h) AND (a[j-h] > v) do
      begin
        a[j] := a[j-h]
        j := j - h;
      end;
     avj] := v;
    end
   until h = 1;

end;

Back to Sorting Algorithms