Advertisement
WarPie90

Untitled

Jul 5th, 2014
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.43 KB | None | 0 0
  1. function heapsort(Arr:TIntArray): TIntArray;
  2. var
  3.   i:Int32;
  4.   data:THeapArrayI;
  5. begin
  6.   for i:=0 to High(arr) do
  7.     hpush(data, Arr[i], i, True);
  8.  
  9.   SetLength(Result, Length(Arr));
  10.   for i:=0 to High(arr) do
  11.     Result[i] := hpop(data, True).value;
  12. end;
  13.  
  14. var
  15.   TIA : TIntArray;
  16.   d:Double;
  17. begin
  18.   TIA := rand.TIA(100,0,10000);
  19.   d := MarkTime();
  20.   TIA := heapsort(TIA);
  21.   WriteLn( MarkTime() - d );
  22.  
  23.   WriteLn(TIA);
  24. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement