-
Notifications
You must be signed in to change notification settings - Fork 0
Class.MinHeap
API Reference / MinHeap
Defined in: min-heap.ts:6
A min heap: the lowest number contained in the heap will always be on top.
-
AbstractHeap
<number
>
new MinHeap():
MinHeap
MinHeap
protected
heap:number
[] =[]
Defined in: abstract-heap.ts:6
insert(
data
):void
Defined in: abstract-heap.ts:26
Inserts data into the heap and bubbles it up to its proper location within the heap.
number
The data to insert.
void
pop():
number
Defined in: abstract-heap.ts:36
Removes the extremum of the heap and returns it.
number
data of type T
peek():
number
Defined in: abstract-heap.ts:56
Returns the extremum of the heap without removing it.
number
data of type T
size():
number
Defined in: abstract-heap.ts:69
Returns the number of items in the heap.
number
The number of items in the heap.
isEmpty():
boolean
Defined in: abstract-heap.ts:78
Returns true if the heap contains no items.
boolean
A boolean value indicating whether or not the heap is empty.
protected
parent(i
):number
Defined in: abstract-heap.ts:87
Returns the index of the parent of the element at i.
number
number
The index of the parent of the element at i.
protected
leftChild(i
):number
Defined in: abstract-heap.ts:96
Returns the index of the left child of the element at i.
number
number
The index of the left child of the element at i.
protected
rightChild(i
):number
Defined in: abstract-heap.ts:105
Returns the index of the right child of the element at i.
number
number
The index of the right child of the element at i.
protected
swap(i
,j
):void
Defined in: abstract-heap.ts:115
Swaps the values of the elements at indices i and j.
number
The index of the first element to swap.
number
The index of the second element to swap.
void
protected
heapifyDown(i
):void
Defined in: min-heap.ts:13
Moves the item at index i down in the heap as long as it is greater than one of its children.
number
The index whose value should be bubbled down through the heap.
void
protected
heapifyUp(i
):void
Defined in: min-heap.ts:41
Moves the item at index i up in the heap as long as it is less than its parent.
number
The index whose value should be bubbled up through the heap.
void