Class MinHeap<T>

Class representing a Min Heap data structure. A Min Heap is a complete binary tree where the value of each node is less than or equal to the values of its children. The root of the tree (the minimum element) can be efficiently accessed or removed, while maintaining heap order.

Type Parameters

  • T

    The type of values stored in the heap.

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Extracts the minimum value (root) from the min heap. After removing the root, it places the last element at the root and performs the bubble-down operation to restore the min-heap property.

    Returns T

    • The minimum value from the heap, or null if the heap is empty.
  • Inserts a value into the min heap. This operation places the value at the end of the heap and then performs the bubble-up operation to maintain the min-heap property, ensuring that each parent node is less than or equal to its children.

    Parameters

    • value: T

      The value to insert into the heap.

    Returns void