The Grey Labyrinth is a collection of puzzles, riddles, mind games, paradoxes and other intellectually challenging diversions. Related topics: puzzle games, logic puzzles, lateral thinking puzzles, philosophy, mind benders, brain teasers, word problems, conundrums, 3d puzzles, spatial reasoning, intelligence tests, mathematical diversions, paradoxes, physics problems, reasoning, math, science.

   
The Grey Labyrinth Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    RegisterRegister  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fast Sorting Algorithm

 
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture
View previous topic :: View next topic  
Author Message
MTGAP
Daedalian Member



PostPosted: Sun Apr 12, 2009 11:12 pm    Post subject: 1 Reply with quote

I am trying to write a program that requires the sorting of a list that contains about 50,000 elements, and I need an efficient sorting algorithm. I was going to use the Quicksort http://linux.wku.edu/~lamonml/algor/sort/quick.html algorithm, but I think it only works if the array of elements contains only numbers from 1 to <number of elements>, which is not the case for my program. I need an efficient algorithm that sorts an array containing any numbers, and it needs to be efficient for sorting 50,000 elements and at the same time not use up all my computer's memory. I am currently using the Shell http://linux.wku.edu/~lamonml/algor/sort/shell.html algorithm, but it seems awfully slow.[/url]
_________________
This statement is false.
Back to top
View user's profile Send private message
wordcross

<memstat>



PostPosted: Sun Apr 12, 2009 11:45 pm    Post subject: 2 Reply with quote

quicksort shouldn't be limited to arrays of a set size. If done correctly it should use recursion to repeatedly halve whatever array you throw at it.
_________________
Has anyone really been far even as decided to use even go want to do look more like?
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
MTGAP
Daedalian Member



PostPosted: Mon Apr 13, 2009 12:57 am    Post subject: 3 Reply with quote

wordcross wrote:
quicksort shouldn't be limited to arrays of a set size. If done correctly it should use recursion to repeatedly halve whatever array you throw at it.

Ah... I was under the impression that quicksort wasn't working because I was inputting the array as being one longer than it actually was, so it was trying to access a nonexistent memory address. Great.

It works now. Thanks for the help.
_________________
This statement is false.
Back to top
View user's profile Send private message
wordcross

<memstat>



PostPosted: Mon Apr 13, 2009 2:45 am    Post subject: 4 Reply with quote

no problem Revenge most foul!
_________________
Has anyone really been far even as decided to use even go want to do look more like?
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Display posts from previous: by   
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Site Design by Wx3