Skip to content
DSA Visualizerpreview

Deque (circular buffer, both ends)

A ring buffer with two moving ends: add or remove at the front or the back in O(1).

O(1) at either end time · O(capacity) space

Operationspush 4, push 7, unshift 2, unshift 9, pop, shift, push 5, unshift 1

An empty ring of 8. push and pop work at the back; unshift and shift at the front.

Ring of 8; front to back: empty.
  • compare
  • swap or write
  • settled

1 / 10

Speed

Space play · ← → step · Home End jump · drag the strip to scrub