Skip to content

Glossary: Coding Interviews in C++

Heap

Also written: min-heap, max-heap, priority queue

A structure that always gives you the biggest (max-heap) or smallest (min-heap) item quickly. Keeping a heap of only k items finds the top k in O(n log k).

Where the book teaches it

Related terms

std::priority_queuestd::greaterstd::partial_sort