FANDOM


A heap is a tree data structure where each node's data is greater than any of its children. Heaps are commonly used as priority queues.

Operations Edit

Common operations on a heap include:

  • Deleting the greatest value in the heap, which is always the root node.
  • Updating a value within the heap.
  • Inserting a value to the heap.
  • Merging two heaps.

Heap sort Edit

A heap sort is carried out by inserting all the items from a list into a heap. The sorted list can then be created by taking the root node and appending it into a list until the heap is empty.

VariantsEdit

See alsoEdit

External links Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.