bottom-up heapsort

Rate this post

I was unable to find a general purpose implementation of bottom-up heapsort, so I’ve made it myself, with a little modification.

You can find the source code on Github: github.com/Maxime2/heapsort

Bottom-up heapsort (bottom-up-heapsort) is a variant of heapsort with a new reheap procedure. This sequential sorting algorithm beats, on an average, quicksort if n > 2400 and a clever version of quicksort (median-3 modification) if n > 16000.

The algorithm of bottom-up heapsort is described in Ingo Wegener, BOTTOM-UP-HEAPSORT, a new variant of HEAPSORT beating, on an average, QUICKSORT (if n is not very small), Theoretical Computer Science 118 (1993), pp. 81-98, Elsevier.

The modification I’ve made saves (n-2)/2 swaps and (n-2)/2 comparisons, for n > 3. It is based on the idea of delayed reheap after moving the root to its place from D. Levendeas, C. Zaroliagis, Heapsort using Multiple Heaps, in Proc. 2nd Panhellenic Student Conference on Informatics — EUREKA. – 2008. – P. 93–104.

2 Responses to “bottom-up heapsort”

  1. dpsearch-4.54-2013-09-15 | Founds Says:

    […] 2 implementations of heapsort: from FreeBSD project and Bottom-Up version. configure script select which one of them and system’s, if present, works […]

  2. Brad Hards Says:

    Have you considered adding this to ccan (http://ccodearchive.net/)?

Leave a Reply


Switch to our mobile site