Binary Heap A binary heap is the complete binary tree which satisfies the heap properties.
- Source:
Example
import { Heap } from '../../ds/heap';
const minHeap = new Heap<number>((a, b) => b - a);
minHeap.add(5);
minHeap.add(2);
minHeap.add(3);
minHeap.add(7);
console.log(minHeap.top); // 2
console.log(minHeap.extract()); // 3
console.log(minHeap.extract()); // 5