Selection sort in java

Previous
Next
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.

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

Java program to implement Selection sort:


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)

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog