Explanation

The outer ``for'' loop at iteration j has data[0] through data[j-1] sorted.

The inner ``for'' loop slides the next item into its place.


next up previous
Next: Step 2: Prove Correctness Up: INSERTION SORT Previous: Step 1: Develop Algorithm