what is the fastest algorithm to order an large amount of numbers?
Could someone write a simple example please? i've already tried bubble sort but it's extremly slow!!!
what is the fastest algorithm to order an large amount of numbers?
Could someone write a simple example please? i've already tried bubble sort but it's extremly slow!!!
lol
too many edits on this
yeah, have you looked into qsort? I was not sure if that was a good function for sorting numbers or not.
Last edited by kermit; 03-16-2004 at 06:12 PM.
sorry my mistake. is qsort ansi-c? it has to be Ansi-C!
>i've already tried bubble sort but it's extremly slow!!!
Bubble sort is second only to Bogo sort in suckiness.
>Could someone write a simple example please?
Check the contest forum. A recent thread has an implementation of quicksort.
>is qsort ansi-c?
Yes.
My best code is written with the delete key.
well you will find it in stdlib.h, if that helps - yeah it is standard C
>>Bubble sort is second only to Bogo sort in suckiness.
And what is this 'Bogo sort' you speak of?
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
>And what is this 'Bogo sort' you speak of?
Take a deck of cards. Throw them in the air and let them fall to the floor. Check to see if they're sorted. Repeat until they are. That's the equivalent of Bogo sort.
My best code is written with the delete key.
Gah!
Nothing like O(∞) efficiency!
Last edited by XSquared; 03-16-2004 at 06:57 PM.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
I thought bogosort was O(N!)
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Radix sort is pretty fast, look it up.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
Bucket sort is pretty much the fastest sort, with a complexity of O(N). It uses huge amount of memory though, and is in most cases not practical especially when having duplicates.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
I'm just going by Prelude's description, so in the worst case it would be O(∞).Originally posted by Salem
I thought bogosort was O(N!)
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Yeah, actually it doesn't have an O value as such.
It is a probablility, that being 1 : N! of actually coming up with the right answer in any given trial.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I wonder how many monkeys it would take to implement the bogo sort?
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
depends how fast you want it one monkey could implement it just fine, except the monkey might die before completing the process.
"never argue with an idiot, they will drag you down to their level and beat you with experience"