Homework 15: Sorting

Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.


Suppose you have the array of numbers [3 2 5 4 1].

A. (1 point) In the style we showed in class, show the contents of the array after each swap step during a selection sort. Underline the most recently sorted element at each step, and use a vertical bar (|) to show the division between the sorted and the unsorted part of the array.

B. (1 point) In the style we showed in class, show the contents of the array after the each swap step of an insertion sort. Underline the most recently sorted element at each step, and use a vertical bar (|) to show the division between the sorted and the unsorted part of the array.