Sorting Practice Quiz¶
Question 1¶
Rearrange the following to show the appropriate steps that occur during one pass of the bubble sort algorithm. The initial order of the list is [11, 7, 3, 14, 8, 6, 9, 2].
Question 2¶
- [1, 9, 19, 7, 3, 10, 13, 15, 8, 12]
- This answer represents three swaps. A pass means that you continue swapping all the way to the end of the list.
- [1, 3, 7, 9, 10, 8, 12, 13, 15, 19]
- Very Good
- [1, 7, 3, 9, 10, 13, 8, 12, 15, 19]
- A bubble sort contines to swap numbers up to index position passnum. But remember that passnum starts at the length of the list - 1.
- [1, 9, 19, 7, 3, 10, 13, 15, 8, 12]
- You have been doing an insertion sort, not a bubble sort.
sorting-quiz2: Suppose you have the following list of numbers to sort: [19, 1, 9, 7, 3, 10, 13, 15, 8, 12] Which list represents the partially sorted list after three complete passes of bubble sort?
Question 3¶
- [7, 11, 12, 1, 6, 14, 8, 18, 19, 20]
- Selection sort is similar to bubble sort (which you appear to have done) but uses fewer swaps
- [7, 11, 12, 14, 19, 1, 6, 18, 8, 20]
- This looks like an insertion sort.
- [11, 7, 12, 14, 1, 6, 8, 18, 19, 20]
- This one looks similar to the correct answer but instead of swapping the numbers have been shifted to the left to make room for the correct numbers.
- [11, 7, 12, 14, 8, 1, 6, 18, 19, 20]
- Selection sort improves upon bubble sort by making fewer swaps.
sorting-quiz3: Suppose you have the following list of numbers to sort: [11, 7, 12, 14, 19, 1, 6, 18, 8, 20] Which list represents the partially sorted list after three complete passes of selection sort?
Question 4¶
Rearrange the following to show the results of each pass of the selection sort algorithm. The initial order of the list is [11, 7, 3, 14, 8, 6, 9, 2].
Randomized Practice Questions¶
- You can practice sorting by hand using bubble and selection sort here: