Loading page…
A hospital triage desk always needs the most urgent patient, not the first one. That is a priority queue, and a heap builds one. The lecture shows the two heap rules, how a heap lives in an array with index arithmetic, how push sifts up and pop sifts down, heapify, how a small heap keeps the best k of a stream, every operation with its cost, and the classic mistakes.
You are building the waiting list for a hospital triage desk.