Selection Sort Algorithm - The Coding Shala
Home >> Algorithms >> Selection Sort In this post, we will learn what is Selection Sort Algorithm and how to implement Selection Sort in Java. Selection Sort Algorithm The selection sort algorithm is a sorting algorithm that sorts an array by repeatedly finding minimum element(ascending order)/maximum element(descending order) from the unsorted part and put it at the beginning of the unsorted array. This algorithm maintains two subarrays in a given array, one is sorted and the second is the remaining unsorted subarray. Working of Selection Sort Algorithm We follow the below steps to implement the Selection Sort Algorithm: Step 1. We pick the minimum element from the unsorted subarray. Step 2. Swap it with the first element of the unsorted subarray. Step 3. Now the first element of unsorted subarray becomes a part of the sorted subarray. Here is an example that explains the selection sort algorithm: Array: 64 25 12 22 11 ...