Skip to main content

Binary Heaps, Priority Queues & Top-K

Pointerless complete binary tree in a flat array (`(i-1)//2`, `2i+1`, `2i+2`), O(n) heapify, and O(n log k) Top-K.

Open the lesson