Home / Computing / Comparing sorting algorithms

Comparing sorting algorithms

Sort the same array and watch comparisons and swaps.

    CS01 · Comparing sorting algorithms0.00 s · Ready

    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

    1. Sort the same array and watch comparisons and swaps.
    2. Run and record each of the three reference settings.
    3. 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.