Hi Andrew,
You wrote to Herman Schonfeld:
AF> I'm not entirely sure of your objectives with this test,
AF>if memory constraints are insignificant, some of these
AF>comments are useless.
AF> Assorted comments and declarations have been removed.
AF> HS> char data[1000][4];
AF> HS> char save[1000][4];
AF> HS> void QKSORT()
AF> HS> {
AF> HS> /* Implementation of QUICKSORT algorithm */
AF> HS> char temp[20];
AF> HS> static int sl[1000][2];
AF> I'd say that this is somewhat overstated. In a worst case
AF>(memory wise) the list will continually be split into
AF>groups of 2, the pivot, and the rest. With a group of 1 or
AF>0, the pivot, and the rest, the first group is sorted and
AF>can be forgot. Thus, the amount of temporary storage peaks
AF>1/3 the total list size in the worst case, so 334 would be
AF>enough.
It's way overstated. If he followed the well known technique of putting
the larger partition on the stack and sorting the smaller one he would
only need (for this case) a stack of "int sl[10][2]" (or, with his
wasteful technique of increasing the stack pointer _before_ putting the
data on the "stack" so that sl[0][x] is never used, "int sl[11][2]").
George
* SLMR 2.1a * Wastebasket: Something to throw things near.
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)
|