Linear Data Structures

Concept shape

Core
0
1
2
3
4
5
Definition

A deque supports adding and removing from both ends.

Step 1 / 5
Concept shape
Current lesson

Deque Lab

Linear Data Structures Core

Deque

Welcome to the Deque concept lab. A deque supports adding and removing from both ends. The must know points are: Can behave as a stack or queue. Useful for window problems. Both ends should be O(1). The common operations are: pushFront O(1), pushBack O(1), popFront O(1), popBack O(1). The complexity shape is Core operations O(1). Watch out for these pitfalls: Implementing with an array API that makes front operations O(n). Related algorithms include Sliding Window Maximum, BFS.

Concept details

A deque supports adding and removing from both ends.

Must know

  • Can behave as a stack or queue.
  • Useful for window problems.
  • Both ends should be O(1).

Complexity

Core operations O(1)

Open deeper visual structure lesson
1.0x