Insertion Sort Visualizer

Current line Previous line
pseudocode.java
j: - p: - temp: -
for (int j = 1; j < n; j++) { int temp = elements[j]; int p = j; while (p > 0 && temp < elements[p-1]) { elements[p] = elements[p-1]; p--; } elements[p] = temp; } // done ✅
j (Outer Loop)
p (Possible Index)
Shifting Right
The "Hole"
Sorted Prefix
Press Step or Play to begin.
while (p > 0 && temp < elements[p-1]) { ... }
j: -
p: -
temp: -

Comparisons: 0
Shifts: 0
Insertions: 0
Passes: 0