← Back to Algorithms

Insertion Sort

Builds the final sorted array one item at a time by repeatedly inserting a new element into the sorted portion of the array.

Current Operation

Click 'Sort' to start visualization

Step: 0/0

Time Complexity: O(n²)
Space Complexity: O(1)

How it Works

Step-by-Step Process:

1. Start from the second element

2. Compare with previous elements and insert in correct position

3. Shift larger elements to the right

4. Repeat until array is sorted