A binary heap is a complete binary tree stored in an array that maintains the heap property: in a min-heap, every parent is ≤ its children, so the minimum is always at the root. This makes it the standard implementation of a priority queue.
Array layout
text
1 index: 0 1 2 3 4
/ \ array: [1, 3, 5, 8, 4]
3 5 parent(i) = (i-1)//2
/ \ left(i) = 2i+1
8 4 right(i) = 2i+2
Operations
python
