Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting.....
#1
is merge sort the fastest sorting routine?
if not, then please post a different routine...i don't care if its messy or not...as long as i understand, then I'll be happy

Oz
Reply
#2
i'm pretty sure quicksort is the fastest general sorting routine around.
oship me and i will give you lots of guurrls and beeea
Reply
#3
It is. In general, as Blitz said.

It often depends on what application you are gonna use it in. Some algos fit better than others.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
im going to be sorting HUGE arrays.....oracle said a while ago that mergesort was teh quickest, and i translated a c mergesort.....ubt im not sure...

this is what i want the sort to do [i have a general idea how]:
-smart manage -> if the specific index doesn't matter, skip it
-sorts so largest is first
-may be comparing with multiple arrays [not sure yet]

Array setup:

FULL [holds all data]
ACTIVE [holds all data in use]..this array will be used for the rest of the current loop for optimization
DEAD [holds all ununsed current data]..this array will be cleared, to free up as much memory as possible...the FULL array will still hold all DEAD data

Oz~
Reply
#5
There are things to take in account, for example: Will you have to resort after a few modifications (i.e. an almost-ordered array), or you will resort being sure that the array is really garbled?

Anyhow, I'd suggest you to use the best iterative version of Quicksort you can find.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
i got some stuff [url="http://members.lycos.co.uk/brisray/qbasic/qsort.htm"]here[/url]

Oz~
Reply
#7
Mergesort is stable, and won't blow out to a huge cost if the stuff to sort is nearly unsorted (quicksort is about as bad as bubblesort on reverse sorted arrays!). However, for a general array that is "averagly" unsorted, quicksort is not only faster, but uses less memory than mergesort.
Reply
#8
If you want to see how the algorithms work and which algorithms there are more, you can also check out the SORTDEMO.BAS file in your QB root folder (it's an example that came with the QB distribution package).
Reply
#9
Oz,
Do you really need to have all your data in arrays? Have you considered writing your data onto plain 'ol flatfiles?

If you decide that you must work with the data in arrays and have to sort these, get into
www.EthanWiner.com
and download his free Basic programming book (it's famous). Here you'll find an excellent Quicksort routine in Basic.
Get this book anyway. It's loaded with Basic info and goodies.
Also, if the data portion of your elements to be sorted are rather large (long), then, for speed, you might consider sorting the indexes of the data and not the data itself. Later you pick up data via its index. (See Indexed Sorts in CHAP8.TXT of the book).

If you can sort the data on flatfiles, see
www.OptTech.com
for the best file sorting utilites you will ever find. I've been using them for 20 years. These people are experts dedicated to sorting.

Let us know what you decide.
*****
Reply
#10
Quote:If you want to see how the algorithms work and which algorithms there are more, you can also check out the SORTDEMO.BAS file in your QB root folder (it's an example that came with the QB distribution package).

You're right, Neo, SortDemo is good for learing about different sort algorithms. You can put in your own sort versions and ideas, and see them run against the standards.

I don't remember if it had a QuickSort. I added a version of QuickSort by Ethan Winer, and it beat all the others.
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)