Lab 7 - Sorting
Due: Wednesday at 5:00pm
This lab is worth 10 points.
There is no coding for this lab. Answer the following questions. You can send
me an email with your answers (use on plain text or PDF format, no Word docs)
or turn in a hand-written answer.
- (6 points) Sort the array 59, 24, 10, 45, 78, 32, 29, 63, 82, 95 using the
following algorithms. Show all work as specified by each algorithm.
- Selection sort. Show each pass (where slot i is replaced with the
minimum of slots i through n).
- Bubble sort. Show each swap of neighbors when they occur during a pass.
- Insertion sort. Show each pass (where a hole is opened up in elements 1
through p-1 to insert the p-th element).
- (4 points) Give the pseudocode for a modified insertion sort that sorts an
index table instead of the actual list. The insertion sort will be passed
the index table, the list to be sorted and the number of elements in the
list. At the end of this modified insertion sort, the index table will
reflect the sorted order of the list and the list will NOT be modified.