Heapsort

This is a discussion on Heapsort within the C++ Programming forums, part of the General Programming Boards category; Where can I found a good implementation of heapsort? (I don't care if it's C++ or C) Google didn't help ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    52

    Heapsort

    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.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I typed "C++ heapsort" into google, and most of the results on the first two pages had implementations.

  3. #3
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    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.

  4. #4
    Registered User
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    52
    The best result till now is this:
    http://en.wikibooks.org/wiki/Algorit...rting/Heapsort

    Thanks for your replies though.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Quote Originally Posted by myle View Post
    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"

  6. #6
    dra
    dra is offline
    Weak. dra's Avatar
    Join Date
    Apr 2005
    Posts
    166
    Here's an awesome article about various sorting algorithms including Heapsort

    http://www.eternallyconfuzzled.com/t...t_sorting.aspx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heapsort
    By xENGINEERx in forum C Programming
    Replies: 2
    Last Post: 03-30-2008, 08:17 PM
  2. heapsort help please!
    By MAC77 in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2005, 12:28 PM
  3. Heapsort
    By abalfazl in forum C Programming
    Replies: 2
    Last Post: 08-06-2005, 07:11 PM
  4. heapsort problem...
    By talz13 in forum C++ Programming
    Replies: 9
    Last Post: 09-23-2003, 05:06 PM
  5. heapsort help plz
    By nsssn73 in forum C# Programming
    Replies: 0
    Last Post: 06-02-2002, 07:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21