
Sorting Exercises
Insertion Sort
1. Perform Insertion Sort on the list
{7, 3, 9, 4, 2, 5, 6, 1, 8}
Showing the resulting list after each pass
a. How many exchanges were made?
b. How many comparisons were made?
c. Demonstrate that a list of 9 elements, in increasing order, produces the best performance
(count the comparisons and swaps).
d. Demonstrate that a list of 9 elements, in decreasing order, produces the worse
performance (count the comparisons and swaps).
Selection Sort
1. Perform Selection Sort on the list
{7, 3, 9, 4, 2, 5, 6, 1, 8}
Showing the resulting list after each pass
a. How many exchanges were made?
b. How many comparisons were made?
c. What is the performance for a list in increasing order?
d. What is the performance for a list in decreasing order?
Bubble Sort
1. Perform Bubble Sort on the list
{7, 3, 9, 4, 2, 5, 6, 1, 8}
Showing the resulting list after each pass
a. How many exchanges were made?
b. How many comparisons were made?
c. What is the performance for a list in increasing order?
d. What is the performance for a list in decreasing order?