Computer Sciences > GATE 2025 SET-2 > Stack Operations
Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and that all keys are distinct.
We wish to augment the stack data structure with an O(1) time MIN operation that returns a pointer to the record with smallest key present in the stack
1) without deleting the corresponding record, and
2) without increasing the complexities of the standard stack operations.
Which one or more of the following approach(es) can achieve it?
A
Keep with every record in the stack, a pointer to the record with the smallest key below it.
B
Keep a pointer to the record with the smallest key in the stack.
C
Keep an auxiliary array in which the key values of the records in the stack are maintained in sorted order.
D
Keep a Min-Heap in which the key values of the records in the stack are maintained.

Explanation

Correct : a

Similar Questions

What is the worst-case time complexity of insertion in an AVL tree?
Question #23 Medium
Which operations on a binary search tree have O(h) complexity?
Question #31 Easy
Compare search complexities of sorted array vs balanced BST.
Question #47 Hard

Related Topics

Data Structures Binary Search Tree Time Complexity Algorithm Analysis Tree Algorithms Computer Science