![]() |
Bubble Sort Exploration(Part 2) |
Before starting another run, record how many swaps and comparisons were done by the last run. Now we want to see how the initial data ordering affects the run-time. Record the number of swaps and comparisons made by each of the following runs.
| Algorithm | Initial Data | Speed | Amount of Data |
| Bubble | Sorted | Fast | 150 |
| Algorithm | Initial Data | Speed | Amount of Data |
| Bubble | Reversely Sorted | Fast | 150 |
What do you notice about the number of comparisons? Explain why that is true.
Run these experiments again and record the number of swaps.
| Algorithm | Initial Data | Speed | Amount of Data |
| Bubble | Random | Fast | 150 |
| Algorithm | Initial Data | Speed | Amount of Data |
| Bubble | Sorted | Fast | 150 |
| Algorithm | Initial Data | Speed | Amount of Data |
| Bubble | Reversely Sorted | Fast | 150 |
Compare these results to the results of your first runs. Why did the number of swaps change for the random data, but not for the others?