Question 1
4 marksTrace insertion sort on [7, 3, 5, 2]. Give the entire list after each completed insertion, and explain why the current item is saved in key.
Show solution and marking guidance
Indicative answer:
- After inserting 3:
[3, 7, 5, 2](1). - After inserting 5:
[3, 5, 7, 2](1). - After inserting 2:
[2, 3, 5, 7](1). - Saving key preserves its value while shifts overwrite its original list position (1).