Jump to content

C++ Language/Std/Stl/Adapters/BinaryHeap

From Wikibooks, open books for an open world

A "binary-heap" data structure maintains the theoretical "heap-property" in a "shaped-tree" whose maximum-item is always at the tree's root. This std::priority_queue<int> binary-heap is useful if you need to be able to frequently identify and remove the largest item in a collection, without that collection having been linearly-sorted.

Additional information about binary-heaps (includes interactive examples)