ds/heap

Binary Heap A binary heap is the complete binary tree which satisfies the heap properties.

Author:
  • Gaurav Soni
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

Classes

Heap