Class MaxHeap<T>

Class representing a Max Heap data structure. A Max Heap is a complete binary tree where each node's value is greater than or equal to the values of its children.

Type Parameters

  • T

    The type of values stored in the heap.

Constructors

Accessors

Methods

Constructors

Accessors

Methods

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

    Returns T

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

    Parameters

    • value: T

      The value to insert into the heap.

    Returns void