Henry Wang
Henry Wang

Reputation: 171

When would someone ever use selection sort?

If there are so many faster and more efficient sorting algorithms available (merge sort, heap sort, quick sort), why is selection sort still taught? If it is because they are still used, when are some examples where this would be true?

Upvotes: 3

Views: 1889

Answers (3)

Kewal Takhellambam
Kewal Takhellambam

Reputation: 101

Selection sort has a few advantages

  1. Less memory write compare to other algorithms. So,may be useful for disk operations or in ROMs. Also an in-place sort.
  2. It is the basic idea of Heap Sort.

Upvotes: 0

Sebastian Van Rooyen
Sebastian Van Rooyen

Reputation: 91

Personally, Selection Sort only exists as a teaching process, besides that, I wouldn't see any other reason to use it.

If gives you a great understanding on Big-O and it's effective to compare selection sort to quick sort/merge sort/heap sort so that you can actually experience the difference in run-time

In short. Selection sort is used for educational purposes 😂

Upvotes: 0

Mike
Mike

Reputation: 5172

I believe it's still taught because it's a simple algorithm to understand and helps build the foundation for other sorting algorithms. It's also an easy exercise in understanding time and space complexity for algorithms. Not aware of any practical usages in modern computing, but it does have very low memory overhead so can be ideal for situations where memory is at a premium.

Upvotes: 2

Related Questions