Step 2: Prove Correctness

Does this actually work?

Proof by induction.

Lemma: After iteration j (1 through n-1), keys 0 through j are sorted.

Proof:


next up previous
Next: Step 3: Efficiency Up: INSERTION SORT Previous: Explanation