BinaryHeap
Binary Heap Implementation that implements the 'insert' and 'remove' methods of the IBinaryHeap interface. Example use is for k-way merge sorting of k sorted arrays. Performance is O(n log n) for initialization (could be further optimized), O(log n) for insertion and O(log n) for deletion
Implements
Constructors
Constructor Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
nodes Required | Array<INode<>> | ||
cmptr Required | comparator<> | ||
direction Optional | "ASC" | "DESC" | "ASC" as HeapDirection |
Methods
remove
Removes either the minimum or the maximum node, depending on heap implementation
Returns
the min/max node or null if heap is empty.
INode<> | null
Class defined in search/src/util/merge-sort/merge.ts:143
Returns a readonly version of the heap as an array