Why are there so many sorting algorithms?

  • Some (Bubble sort) are simple to implement, and thus useful for teaching.
  • Some (Merge sort, Heap sort) have a relatively low limit on the worst-case number of operations they have to perform. If they need to sort N elements, they will never need more than O(N log N). Note: see here for a definition of O()
  • Some (Insertion sort, Cube sort) have a low number of “best case” operations, meaning that they finish quickly if the list of already sorted. For N elements, their best case will be O(N)
  • Some (Heap sort) need very little memory
  • Some (Bead sort) only work with positive integers
  • Some… well, you get the point.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yuval Boger

Yuval Boger

48 Followers

Yuval Boger — The Qubit Guy — talks about business and technical subjects related to quantum computing and technologies. Reach him at https://bit.ly/3yl4bxp