home *** CD-ROM | disk | FTP | other *** search
- Program TestHeaps;
-
- Uses Heaps,Crt;
-
- Const
- Num = 200; {I have successfully sorted 250,000 integers on}
- {my humble little 6.44 mhz 8088 based XT-clone.}
- {Time check was 9hrs, 12 minutes. -- ECW }
-
- Var
- H : IntHeap;
- I : LongInt;
- J : Integer;
-
- Begin
- ClrScr;
- Randomize;
-
- WriteLn (MemAvail,' Bytes Available before Initialization.');
-
- H.Create;
- H.Init(Num);
-
- WriteLn (MemAvail,' Bytes Available after Initialization.');
- WriteLn;
- WriteLn ('SORTING ',Num,' INTEGERS.');
-
- For I := 1 to Num do
- Begin
- J := 1 + Random (MaxInt);
- GoToXY (1,5);
- Write ('Sifting Up ',I,'th Element.');
- H.SiftUp (J,I)
- End;
-
- GoToXY (1,6);
- ClrEol;
- Write ('Sorting');
- H.Sort;
- WriteLn;
-
- For I := 1 to Num do WriteLn (H.Retrieve(I),' was the ',I,'th Element');
-
- ReadLn;
-
- ClrScr;
- WriteLn ('Building Heap from Scratch and then Sorting.');
-
- H.BuildHeap;
-
- WriteLn ('Heap Built. Sorting...');
-
- H.Sort;
-
- For I := 1 to Num do WriteLn (H.Retrieve(I),' was the ',I,'th Element');
-
- H.Destroy;
-
- ReadLn;
-
- End.