Computing · Algorithms / Principles and exploration
Comparing sorting algorithms experiment guide
Sort the same array and watch comparisons and swaps.
How does it work?
Comparison counts depend on size, initial order, and algorithm.
Key relationship
bubble: n(n−1)/2 · merge: O(n log₂n)
Try this investigation
- Sort the same array and watch comparisons and swaps.
- Run and record each of the three reference settings.
- Change one variable and compare with the reference records.
Interpreting your results
Are merge writes and swaps the same operation?
Different operations · Comparison counts depend on size, initial order, and algorithm.
Assumptions and limitations
We count value comparisons and swaps rather than elapsed time. Merge writes are separate.