Developer

This experience deserves a bigger screen

The DSA Visualizer is designed for deep focus,
side-by-side code, and real-time execution insight.

On small screens, that level of clarity can't be preserved.

Open on a tablet (landscape) or desktop for the intended experience.

Desktop experience preview

Insertion SortStep-by-Step Visualization

Insertion Sort builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

Problem Statement

Sort an array of integers using Insertion Sort.

Approach

Iterate from the second element to the last. For each element, store it in a temporary variable and shift elements of the sorted segment (to its left) that are greater than it one position to the right. Insert the element in its correct position.

Time & Space Complexity

Time complexity is O(n^2). Space complexity is O(1).

Interactive Visualization

Loading Interactive Visualizer...

Click "Play" or use arrow keys to step through the execution.