Algorithms and Data Structures · Junior · Question 18 of 75
What does the stack data structure guarantee?
- 1First in, first out (FIFO)
- ✓Correct answer: Last in, first out (LIFO)
- 3Elements always come out sorted
Explanation
A stack returns the most recently added element first, like a stack of plates. In JavaScript an array with push and pop is a ready-made stack with O(1) operations.