The "Swiss Army Knife"
Because you can `push_front`, `push_back`, `pop_front`, and `pop_back`, a Deque can emulate a Stack (using only push_back/pop_back) OR emulate a Queue (using push_back/pop_front).
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A specialized, highly flexible queue where insertion and deletion can occur at BOTH ends. It combines the capabilities of both Stacks and Queues.
Because you can `push_front`, `push_back`, `pop_front`, and `pop_back`, a Deque can emulate a Stack (using only push_back/pop_back) OR emulate a Queue (using push_back/pop_front).
Typically implemented via a doubly-linked list or a circular array. Modern language standard libraries (like C++ `std::deque` or Python `collections.deque`) highly optimize this structure for O(1) operations on both ends.