Selection Sort
Selection Sort
-> A non comparison sort on the other hand is are algorithms which are not
comparison based.
For example: Counting sort and Radix Sort.
~Selection Sort~
Sorts the array by repeatedly finding the smallest element, it manages two sub
arrays one being the sorted array and one being the unsorted array to be sorted In
every iteration one unsorted element is moved to the sorted array.
In laymen terms, Selection sort is an sorting algorithm which picks up the smallest
element from an array and swaps it with the unsorted element in the beginning.
APPLICATION:
-> Efficient for sorting small data sets.
-> Hardware level sorting.
-> Often used to teach sorting due to its simplicity.
CODE:
import java.util.*;
class SelectionSort{
static int[] sort(int arr[]){
int n = arr.length;
arr = sort(arr);
printArray(arr);
}
}