Keep a min-heap in a plain list
A heap is a tree stored in a list: the children of index i sit at 2i+1 and 2i+2, and every parent is no larger than its children. The smallest item is always at index 0.
heap = [1, 4, 2, 9]
i = 3
print((i - 1) // 2) # parent index 1Think before coding
Push appends and sifts the new item up while it is smaller than its parent. Pop moves the last item to the root and sifts it down, swapping with the smaller child. Both take about log2(n) swaps. Work through the example by hand before changing the starter. Decide what should happen for an empty input, a single value and a repeated value where those cases apply. The checks use several inputs so a hard-coded answer cannot stand in for the rule.
Your task
Write push(heap, value) and pop(heap) for a min-heap kept in a list, without the heapq module. pop removes and returns the smallest item.
The explanation opens here once every check passes.