📥 Insertion Sort Invariant

Insert each element into its correct position in the sorted prefix

Click "Next Step" to begin sorting.
Sorted
Sorted Prefix
Key (inserting)
Comparing
Unsorted
📐 Loop Invariant: At the start of each iteration, the subarray A[0...i-1] consists of the elements originally in A[0...i-1], but in sorted order.
✓ Initial: A[0] (single element) is trivially sorted.