Skip to content

Worst case sort time is actually O(n**2), not O(n * log(n)) #1

@tanriol

Description

@tanriol

Counter-example:

    elif array_type == 'X-shaped':
        random_data = [abs(i - size // 2) * ((-1) ** i) for i in range(size)]

Benchmarking results for this example on my machine

--- X-shaped ---
Array Size |  Merciful Stalin (s) |  Merge Sort (s) |  Quick Sort (s) | Bubble Sort (s) | Insertion Sort (s)
------------------------------------------------------------------------------------------------------------
       100 |             0.000406 |        0.000162 |        0.000385 |        0.000512 |           0.000206
       500 |             0.008444 |        0.000899 |        0.011718 |        0.016313 |           0.006826
     1,000 |             0.042343 |        0.001878 |        0.046340 |        0.069664 |           0.027881
     2,000 |             0.151176 |        0.004479 |        0.192380 |        0.297812 |           0.119710
     5,000 |             0.968564 |        0.014908 |        1.235482 |        2.013621 |           0.799174
    10,000 |             3.840734 |        0.027826 |        4.871039 |        7.971764 |           3.138844
    20,000 |            15.662325 |        0.053856 |       19.865934 |       32.706325 |          13.008377

X_shaped
Merciful_Stalin_Sort_Performance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions