Priority Queue — Same ADT, Three Backings

Operations Push / Pop / Peek executed in parallel on a binary heap, sorted array, and BST. Watch comparisons and moves diverge.

500ms

Binary Heap push/pop O(log n)

Complete binary tree, array-backed. Sift up/down on mutation.
array index view
cmp0
mov0
size0

Sorted Array push O(n) · pop O(1)

Linear scan + shift on insert. Pop from tail in priority order.
sorted by priority (head = next pop)
cmp0
mov0
size0

BST (unbalanced) avg O(log n) · worst O(n)

Plain BST keyed by priority. Pop walks to extreme leaf.
cmp0
mov0
size0

Step Narration

Ready. Add elements with Push, or click Random to seed a queue.
default
active
comparing
inserted
path
extracted

Operation Log