Archived

This topic is now archived and is closed to further replies.

Mulligan

The heap sort

Recommended Posts

Mulligan    378
The sort efficiency for a heap sort is always the same. Does that mean that there are no best/worst case lists for a heap sort to sort?

Share this post


Link to post
Share on other sites
Miserable    606
A very slight difference. If you implement it so that you don''t have to swap at every level (just keep the value you bubble up or down to the side), you''ll have to make about log(n) copies (base 2, of course) in the worst case. I''m no expert on algorithm analysis, but at a guess, this would happen fairly often, in about 50% of the cases with a full leaf level. Still, no matter what, Heap Sort is O(log(n)), which is pretty good.

Share this post


Link to post
Share on other sites