Concept: constant-time access at the heap root
The top element is always at the root, which is index 0 of the underlying array. No traversal, no swaps - a constant-time array read, **O(1)**.
What is the time complexity of peeking at the top (max or min) of a binary heap?
Concept: constant-time access at the heap root
The top element is always at the root, which is index 0 of the underlying array. No traversal, no swaps - a constant-time array read, **O(1)**.