Pattern7 visualizers
Heap / Priority Queue Pattern Visualizers
The Heap / Priority Queue pattern is a recurring algorithmic shape that appears across coding interviews and competitive problems. Use it when the problem geometry matches its trigger conditions — recognizing the pattern collapses what looks like a hard problem into a familiar template. These visualizers trace Heap / Priority Queue step-by-step on classics such as Find Median from Data Stream, Kth Largest Element in a Stream, Kth Largest Element in an Array, so you can internalize the moves before you ever need them under pressure.
Heap / Priority Queue
Find Median from Data Stream
Computes the running median of an incoming stream of numbers efficiently by balancing a Max-Heap and a Min-Heap.
Open visualizer →
Heap / Priority Queue
Kth Largest Element in a Stream
Maintain a size-k min-heap across streamed adds so the root is always the current kth largest.
Open visualizer →
Heap / Priority Queue
Kth Largest Element in an Array
Keep a min-heap of size k while scanning nums; the root ends up as the kth largest.
Open visualizer →
Heap / Priority Queue
Kth Smallest Element in a Sorted Matrix
Seed a min-heap with the first column, then pop k-1 times, pushing each popped cell's right neighbor.
Open visualizer →
Heap / Priority Queue
Last Stone Weight
Repeatedly smash the two heaviest stones in a max-heap until at most one stone remains.
Open visualizer →
Heap / Priority Queue
Min-Heap Operations
Insert values with bubble-up, then extract-min with sift-down. Watch the tree and array in sync.
Open visualizer →
Heap / Priority Queue
Top K Frequent Elements
Count frequencies, then push into a min-heap keyed by frequency and cap it at size k.
Open visualizer →