Correct option is C
A
deque (double-ended queue) is a
linear data structure that allows
insertion and deletion from both the front and rear ends. It is a
generalization of a queue where elements can be added or removed from either end.
Important Key Points:
1.
What is a Deque?
· A
deque (double-ended queue) allows insertion and deletion from
both ends.
· It can be
used in scheduling, caching, and sliding window algorithms.
· Two types of deques:
·
Input-Restricted Deque – Insertion from
one end, deletion from
both ends.
·
Output-Restricted Deque – Deletion from
one end, insertion from
both ends.
2. A deque can be efficiently implemented using doubly linked lists or dynamic arrays.
3. Deques are used in algorithms like BFS (Breadth-First Search), caching mechanisms and undo-redo functionality.
Knowledge Booster:
· Python provides a built-in collections.deque for optimized double-ended queue operations.
·
(a) Queue → ❌ Incorrect: A
queue follows FIFO (First In, First Out) and allows
insertion only at the rear and
deletion only from the front.
·
(b) Circular Queue → ❌ Incorrect: A
circular queue allows wrapping around of elements
but does not allow insertion and deletion from both ends like a deque.