Heap

noun

say it: “HEEP” /hiːp/

A tree stored in an array that always keeps the most important item on top, ready to take next.

What is a heap?

A heap keeps the most important item on top, ready to take, like an emergency room that always calls the most urgent patient. It's a complete binary tree stored in a plain array, and adding or removing the top takes O(log n). (Not the same as heap memory, where a program keeps its objects.)

In a sentence

  • “The waiting list is a heap, so the most urgent patient is always at the top.”

Level: Journeyman · More Data Structures terms at this level

Updated