Which data structure allows insertion and deletion from both ends?
- Stack
- Queue
- Deque
- Array
Answer: Deque
Deque (Double-Ended Queue) allows insertion and deletion at both front and rear ends, combining features of stack (LIFO) and queue (FIFO). Implemented using arrays or linked lists. Used in palindrome checking, sliding window problems, and browser history management. Time complexity: O(1) for end operations.