sortingquicksortmergesortbubble-sortinsertion-sort

Sorting algorithm choice


I was wondering which sorting algorithm between bubble sort, insertion sort, merge sort, quick sort and selection sort is the worst to use to sort a list of 100 million elements if you have limited computer space and why?


Solution

  • Probably selection sort. It's inefficient compared to the other options, at a time complexity of Ω(n²), as opposed to bubble and insertion sort at Ω(n) and quick and merge sort at Ω(n log(n)).

    As trincot mentioned above, merge sort would be the worst in this circumstance as it uses auxiliary space while the other three algorithms sort inplace.