Which data structure efficiently supports both LIFO and FIFO operations under different constraints?
15 views
- Deque (Correct Answer)
- Stack
- Queue
- Linked List
Explanation
A deque (double-ended queue) allows insertion and deletion at both ends, enabling it to function as both a stack (LIFO) and a queue (FIFO). This flexibility makes it suitable for applications like sliding window algorithms and palindrome checking.