10. Heaps

In this chapter, we discuss two implementations of the extremely useful priority Queue data structure. The first is an implementation based on arrays. It is very fast and is the basis of one of the fastest known sorting algorithms, namely heapsort (see Section 11.1.3). The second implementation is based on binary trees and is more flexible. In particular, it supports a $ \mathtt{meld(h)}$ operation that allows the priority queue to absorb the elements of a second priority queue $ \mathtt{h}$.