DSA-VerseLearn by watching code run
DashboardData StructuresAlgorithmsVisualizerCORECoding PlaygroundInterview QuestionsComplexity AnalyzerLearning NotesBookmarksLearning ProgressSettings
Instrumented JavaScript implementation · lines sync with the animation

Run to execute this JavaScript code for real (output appears here).

Queue Enqueue and Dequeue

queues
enqueue 10enqueue 20enqueue 30dequeue()enqueue 40enqueue 50enqueue 60dequeue()dequeue()
circular array · data[]
null
0
▲front
null
1
null
2
null
3
rear = −1 (nothing enqueued yet)
in
10
front →(empty)← rear

Size 0 / 4 · FIFO — values leave in the same order they arrived

Just enqueuedLeaving (front)Slot being updated

Ready.

A queue is First-In-First-Out (FIFO): enqueue adds at the rear, dequeue removes from the front. This circular-array queue wraps the rear pointer around to reuse freed slots. Press Run (Ctrl + Enter) to animate, or Step forward (F10) to go one event at a time.

1 / 49

Execution

Step

1 / 49

Line (JavaScript)

—

FUNCTION_CALLoperation 1

Variables

data[null, null, null, null]
front0
rear-1
size0
capacity4
value10

Pointers

front = 0rear = -1
Call stackdepth 1
enqueue(10)← running

Operation counters

No counted operations yet.

Memory (measurable)

Slots used0 / 4
Per-operation extra spaceO(1)

Data structure state

data = [null, null, null, null]