3 The list of numbers below is to be sorted into increasing order.
\(\begin{array} { l l l l l l l l } 23 & 10 & 18 & 7 & 62 & 54 & 31 & 82 \end{array}\)
- Sort the list using bubble sort.
You do not need to show intermediate working.
- Record the list that results at the end of each pass.
- Record the number of swaps used in each pass.
- Now sort the original list using shuttle sort.
You do not need to show intermediate working.
- Record the list that results at the end of each pass.
- Record the number of swaps used in each pass.
- Using the total number of comparisons plus the total number of swaps as a measure of efficiency, explain why shuttle sort is more efficient than bubble sort for sorting this particular list.
Bubble sort and shuttle sort are both \(\mathrm { O } \left( n ^ { 2 } \right)\).
- Explain what this means for the run-time of the algorithms when the length of the list being sorted changes from 1000 to 3000.