How a heap keeps the smallest number on top
How a heap keeps the smallest number on top
The smallest number is always on top.
In a heap every parent is smaller than its children. A new number joins at the bottom and swaps up. A pop takes the top, moves the last number up, and lets it sink back down.
Save it for your next coding interview.
#heap #datastructures #computerscience #coding #programming #technology