/Heap-Data-Structure

The Heap data structure in Python, with the Heap Sort algorithm

Primary LanguagePythonMIT LicenseMIT

Heap-Data-Structure

The Heap data structure in Python, with the Heap Sort algorithm

Heaps are Complete Binary Trees.

The Complete Binary Max-Heap is implemented as an array, which is both fast and memory efficient. It's also easy to code.

There are two variants of heaps here: the one that uses 1-based indexing, and the other that uses 0-based indexing, into arrays. 1-based indexing is faster than 0-based.

Partial sorting is also included in the code.

Priority Queues are usually implemented as Heaps.

The code includes examples.