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

Insertion Sort

sorting
12
11
13
5
6
0
1
2
3
4
ComparingSwapping / movingCurrentSorted / finalFound / placed

Ready.

Builds a sorted prefix one element at a time: the next element (the key) is lifted out, larger elements of the prefix shift one step right, and the key drops into the gap. Press Run (Ctrl + Enter) to animate, or Step forward (F10) to go one event at a time.

1 / 43

Execution

Step

1 / 43

Line (JavaScript)

—

FUNCTION_CALL

Variables

arr[12, 11, 13, 5, 6]
Call stackdepth 0

main (no active function frames)

Operation counters

No counted operations yet.

Memory (measurable)

Extra variablesi, j, key
Auxiliary spaceO(1) — in place

Data structure state

[12, 11, 13, 5, 6]