How a binary heap sifts in an array

Short answer: A binary heap stores a complete binary tree in an array. The parent of index i is floor((i−1)/2), and the children are 2i+1 and 2i+2, for zero-based indexes. The heap property says every parent is ordered before its children. Sift up repairs an insertion at the end.…