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).

Bubble Sort

sorting
5
3
8
1
2
0
1
2
3
4
ComparingSwapping / movingCurrentSorted / finalFound / placed

Ready.

Repeatedly compares adjacent elements and swaps them when they are out of order, so the largest unsorted value bubbles to the end after every pass. 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_CALL

Variables

arr[5, 3, 8, 1, 2]
n5
Call stackdepth 0

main (no active function frames)

Operation counters

No counted operations yet.

Memory (measurable)

Extra variablesn, i, j, swapped
Auxiliary spaceO(1) — in place

Data structure state

[5, 3, 8, 1, 2]