Board index » delphi » Quick Sort Algorithm or Source Code

Quick Sort Algorithm or Source Code

I need an efficient algorithm, or code (if possible) for
QUICKSORT, and only QUICKSORT.

If anyone has this write back to this BBS.

Jason

Re:Quick Sort Algorithm or Source Code

Quote
In article <00009410+00002...@msn.com> Nortch...@msn.com (Jason Dunbar) writes:
>I need an efficient algorithm, or code (if possible) for
>QUICKSORT, and only QUICKSORT.
>If anyone has this write back to this BBS.

Any textbook on data structures should cover sorting algorithms in some
detail.  There are plenty of bad ones out there; some are awful.  But if you
find a good one it's a desktop necessity.

Incidentally, the definitive source on such things is Knuth's "Sorting and
Searching," if you can read it.  ;-)

Re:Quick Sort Algorithm or Source Code

Here is the method I found best suited to the Quick Sort in PASCAL:

RECURSIVE
=========

PROCEDURE Partition ( VAR List   : El_Array, First, Last : integer;
VAR PivInd : integer );

VAR
Pivot : integer;
Up

PROCEDURE Quick_Sort ( VAR List : El_Array; First, Last : integer );

VAR
PivInd : integer;
Up     : integer;
Down

BEGIN
IF ( First < Last ) THEN
BEGIN
Partition  ( List, First, Last, PivInd );
Quick_Sort ( List, First, ( PivInd - 1 ) );
Quick_Sort ( List, ( PivInd + 1 ), Last );
END;
END;