- Push(): add an element into the collection.
- Pop(): return and remove the minimal element from this collection.
- Min(): return but do not remove the minimal element from this collection.
Asked
Active
Viewed 143 times
-4

user1657564
- 29
- 6
2 Answers
2
Suppose such a data structure existed.
Then here is an O(n) comparison-based sorting algorithm:
- Push() every item into this data structure.
- Pop() them all off in sorted order.
No O(n) comparison-based sorting algorithm can exist, therefore no such data structure can exist.

j_random_hacker
- 50,331
- 10
- 105
- 169
0
Constant time push(), pop() and remove is possible in Stack. The below post demonstrates it: