Selection sort is a sorting algorithm which sorts the given array elements either in descending or ascending order by finding the misplaced element first and putting it in it’s final place.
Selection sort algorithm first selects the lowest (or highest) element and places it in the ordered position. Selection sort is recommended only for small size arrays (less than 1000 elements).
It doesn’t give much performance as compared to other sorting algorithms when used on large size arrays.
It has O(n2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort.
Selection sort is noted for its simplicity, and it has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.
Worst case performance : О(n2)
Best case performance : O(n2)
Average case performance : О(n2)
Here is source code of the Java Program to implement Selection Sort. The Java program is successfully compiled and run on a Windows system(NetBeans). The program output is also shown below.
SOURCE CODE : :
OUTPUT : :
need an explanation for this answer? contact us directly to get an explanation for this answer