03-21-2005, 07:47 AM
Yes, it's possible to do a quicksort without recursion; that is, without using the recursion facilities of Qbasic.
What you have to do is keep track of a stack, which is nothing more than an array where you PUSH and POP values. Of course you must understand the idea of a stack.
If you, SBM, are really interested, I have two sub-functions writtten by Ethan Winer which do a quicksort using a stack with PUSH and POP.
The first one, which I have tested thoroughly, was written in 1988, and uses a few goto's. This baby really flies.
The second one, written in 1992, is completely structured, but I have never tested it.
Each have about 30-40 lines of code. If you want, I'll post the code for the one you'd like.
*****
What you have to do is keep track of a stack, which is nothing more than an array where you PUSH and POP values. Of course you must understand the idea of a stack.
If you, SBM, are really interested, I have two sub-functions writtten by Ethan Winer which do a quicksort using a stack with PUSH and POP.
The first one, which I have tested thoroughly, was written in 1988, and uses a few goto's. This baby really flies.
The second one, written in 1992, is completely structured, but I have never tested it.
Each have about 30-40 lines of code. If you want, I'll post the code for the one you'd like.
*****