Deque (Double-Ended Queue)

Circular array implementation — push and pop at both ends in amortised O(1)

pushFront / pushBack — O(1) amortised popFront / popBack — O(1) peekFront / peekBack — O(1) grow — O(n) on resize

Operations

Circular Array (Ring Buffer)

▲ head → index 0
▲ tail → index 0
size = 0
capacity = 8

Logical Deque Order (front → back)

Last Operation

Click an operation to begin.
head (front)
tail (next slot at back)
head ≡ tail (empty or full)
pushing
popping
peeking

Stats

0
Size
8
Capacity
0%
Load factor
0
Grows

Big-O Complexity

OperationTime
pushFrontO(1) amortised
pushBackO(1) amortised
popFrontO(1)
popBackO(1)
peekFrontO(1)
peekBackO(1)
grow (resize)O(n)
random accessO(1)

Operation Log