Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • T

Hierarchy

  • BinaryHeap

Index

Constructors

Properties

comparator: Comparator<T>
size: number
values: T[]

Methods

  • bubbleUp(): void
  • Finds the right spot for a newly added element

    Time complexity: O(logN) Space complexity: O(1)

    Returns void

  • extract(): null | T
  • Extract the root element and set a new one.

    Time complexity: O(logN) Space complexity: O(1)

    Returns null | T

  • insert(value: T): number
  • Add element to the heap

    Time complexity: O(logN) Space complexity: O(1)

    Parameters

    • value: T

    Returns number

    the size of the heap

  • root(): null | T
  • Returns the root element without extracting it.

    NB: Don't modify if it's an object

    Time complexity: O(1) Space complexity: O(1)

    Returns null | T

  • sinkDown(): void
  • Finds the right place for the temporary root

    Time complexity: O(logN) Space complexity: O(1)

    Returns void

  • toString(): string
  • Overrides the generic toString method

    Time complexity: O(n) Space complexity: O(n)

    Returns string

Generated using TypeDoc