Selection sort in java


If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview programs.

Selection sort is an in place comparison sorting algorithm. It is very simple to implement but it does not go well with large number of inputs.

Table of Contents

Selection sort algorithm

  • Find the minimum element in the list.
  • Swap minimum element with current element.
  • Repeat the whole process until array is fully sorted.
Below visualization will make it more clear

Selection sort algorithm

When you run above program, you will get below output:

Time complexity

Best case : O(N^2)
Average case : O(N^2)
Worst case : O(N^2)

To understand more about complexity,please go through complexity of algorithm.


Related posts

Add Comment