Insertion Sort Visualizer & Step Generator
Interactive Insertion Sort step generator showing array shifts and key element insertion.
Insertion Sort
Enter your custom input data → Run the real algorithm engine → Observe step transitions.
⚙️ Customize Algorithm Input Data
Sub-array at index 0 is trivially sorted.
Algorithm state rule requirement
State pointers updated
Mathematical Formula
Overview & Explanation
Insertion sort builds the final sorted array one item at a time, similar to sorting playing cards in hand.
How It Works
- Iterate from arr[1] to arr[n-1].
- Compare current key element with preceding elements.
- Shift elements greater than key one position ahead.
Practical Applications
- Fast sorting for nearly-sorted arrays
- Online real-time stream sorting
Insertion Sort Example
Sorting [12, 11, 13, 5, 6]
Insert 11
Shift 12
Insert 5
Shift 13, 12, 11
Frequently Asked Questions
When is Insertion Sort efficient?
Related Calculators
IPv4 Subnet & CIDR Calculator
Calculate network address, broadcast address, subnet mask, wildcard mask, and usable IP range for any IPv4 address and CIDR prefix.
Bubble Sort Visualizer & Step Calculator
Interactive step-by-step Bubble Sort execution visualizer with comparisons, swaps, and time complexity breakdown.
Selection Sort Visualizer & Calculator
Step-by-step Selection Sort execution visualizer tracking minimum element indices, swaps, and comparisons.
Merge Sort Visualizer
Interactive divide and conquer Merge Sort step generator showing array splitting and merging.