Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
radix vs quiksort
#1
I've always thought that radix(binary sort) would be preferable to quiksort in pqb because pqb is slow with recursion. Anyone care to give me some insight?
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#2
what do you mean with PQB?
Reply
#3
Pure Qb as in the sorting algorithm was coded in pure qb. As opposed to one coded in asm and used as a subprogram
am part of the legion of n00b. We are numerous if dumb. We will enslave you all!
Reply
#4
SBM,

Unless the program that's going to use the sort is mission-critical and the amount of data is very large with a huge sort key, then the issue of speed really doesn't matter. Use whatever sort algorithm that you understand and feel comfortable and confident with.

Later, when the program is working fine and you're not satisfied with the speed (which I doubt), then go back into the program and install a better sort algorithm.

Putting the greatest sort algorithm into a normal program is like putting spoilers on your old 93 VW. You'll never get the car up to the speed where the spoilers will do any good.
*****
Reply
#5
heh, well as for understand the only choice I have is bubblesort. he he. :roll:

Well, I agree with Moneo. I used many different sort subs for my 3D prog. but they all looked exactly the same speed as with bubblesort, so I never took the time to learn others.
i]"But...it was so beautifully done"[/i]
Reply
#6
Quote:I've always thought that radix(binary sort) would be preferable to quiksort in pqb because pqb is slow with recursion. Anyone care to give me some insight?

It's possible to do quicksort without recursion.
roeten van Frenkel
Visit us at The Official S&F PROD. Homepage
Reply
#7
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.
*****
Reply
#8
have you thought of using Heap sort? It's one of the best IMO. It's best case, worst case and average case is same O(nlogn).
Reply
#9
Quote:have you thought of using Heap sort? It's one of the best IMO. It's best case, worst case and average case is same O(nlogn).
I don't doubt that you have had some good experiences with the Heap sort.

I use the old Qbasic SORTDEMO.BAS program for testing sort algorithms. It has the Bubble, Shell, Heap, Quicksort and others. It ranks the algorithms by time. I modified it a few years ago to add some other algorithms, like Ethan Winer's Quicksort, and one of my own. I disabled the Bubble and the Shell.

Anyway, I just ran it a few times and noticed that the Heap sort takes between 3 and 4 times longer than the 2 Quicksort versions and my algorithm. This is in a range of 5 to 25 seconds.

I also looked at the code for the Heap and found that it is quite complicated, with one main subprogram and two additional supporting subfunctions.

If you think you might be interested in this modified version of SORTDEMO.BAS, let me know and I'll email it to you.
*****
Reply
#10
Simply there's no "best sorting algorithm". You can find different scenarios where you can choose which one to use, as no al sets of elements to sort are the same and some algos work better than others depending on the set to sort.

For example, for an almost sorted set of not many elements, the bubble sort works perfectly. Sometimes there's no need to implement an intrincate algorithm.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)