Option A: Keep with every record, a pointer to the record with the smallest key below it.
This is a valid and efficient approach.
Each stack node stores a pointer to the record with the smallest key among all records below it (i.e., deeper in the stack).
When pushing a new element $x$:
- Compare $ x $’s key with the key of the current top’s “min_below” record.
- Set the new node’s “min_below” pointer to point to whichever has the smaller key (either the existing minimum below or $ x $ itself if it’s smaller but note, since $ x $ is on top, “below” means excluding $ x $).
- Then, to compute the global minimum for the MIN operation, compare the new top’s key with the key of the record pointed to by its “min_below” pointer and return the pointer to the smaller one. This is $ O(1) $.
When popping:
Simply remove the top. The new top already has its own precomputed “min_below” pointer no recomputation needed. Thus, PUSH, POP, and MIN all remain $ O(1) $.
$\text{Option A works}$
Option B: Keep a pointer to the record with the smallest key in the stack.
This is insufficient.
While we can update the pointer during PUSH (by comparing the new key with the current minimum), the problem arises during POP.
If the popped element is the current minimum, we must find the new minimum but scanning the stack takes $ O(n) $ time.
Without maintaining additional structure (like a stack of historical minimums), we cannot update the pointer in $ O(1) $ after such a POP.
$\text{Option B fails to guarantee} $ O(1) $ POP$
Option C: Keep an auxiliary array in sorted order.
To maintain sorted order, every PUSH requires finding the correct insertion position $ O(n) $ time.
Similarly, POP requires removing an element and shifting also $ O(n) $.
Although MIN (first element) is $ O(1) $, PUSH and POP are not.
$\therefore$ Violates the requirement of $ O(1) $ standard operations.
Option D: Keep a Min-Heap.
A Min-Heap can return the minimum in $ O(1) $, but insertion and deletion take $ O(\log n) $.
PUSH and POP would no longer be $ O(1) $.
$\therefore$ Violates the requirement.
Only $\boxed{\text{Option A}}$ satisfies all constraints enabling $ O(1) $ MIN while preserving $ O(1) $ PUSH and POP.