Heap operations

Not all implementations of the heap data structures expose the same operational methods. However, the more common operations should be available or made available as needed by the developer.

  • Insert: The Insert operation adds a new node to the heap. This operation must also re-order the heap to ensure that the newly added node maintains the heap property. This operation has an O(log n) operational cost.
  • FindMax: The FindMax operation is synonymous with a max heap, and returns the largest value or highest-priority object in the collection. In an array-based implementation, this is typically the object at either index 0 or index 1, depending on the design. This is equivalent to the peek operation in a stack or queue, which is important ...

Get Everyday Data Structures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.