Where can I found a good implementation of heapsort? (I don't care if it's C++ or C)
Google didn't help me a lot. It would be ideal to find the implementation that is used by some efficient library, or just a (proven?) efficient implementation.
Where can I found a good implementation of heapsort? (I don't care if it's C++ or C)
Google didn't help me a lot. It would be ideal to find the implementation that is used by some efficient library, or just a (proven?) efficient implementation.
I typed "C++ heapsort" into google, and most of the results on the first two pages had implementations.
Library implementations are usually very general and you wouldn't necessarily learn how heap sort works any better than if you wrote a routine to sort a datatype you know, such as int. Keep the implementations you learn from specific until you know the algorithm.
The best result till now is this:
http://en.wikibooks.org/wiki/Algorit...rting/Heapsort
Thanks for your replies though.
What's wrong with that page? (apart from the horrible syntax hilighting colors)
If you want a proven efficient implementation you could read the implementations of make_heap and sort_heap from your favourite C++ compiler. But I think you'll find the ones you linked to a bit more readable.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Here's an awesome article about various sorting algorithms including Heapsort
http://www.eternallyconfuzzled.com/t...t_sorting.aspx