Selection Sort Algorithm - The Coding Shala
In this post, we will learn what is Selection Sort Algorithm and how to implement Selection Sort in Java.
Selection Sort Algorithm
Working of 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.
The time complexity of Selection Sort
The time complexity of the selection sort is O(n^2). There are two nested loops. one for finding min another for every element.
In the selection sort algorithm, the auxiliary space is O(1).
Selection Sort Algorithm Java Program
- Radix Sort Algorithm
- Quick Sort Algorithm
- Merge Sort Algorithm
- Insertion Sort Algorithm
- Sliding Window Algorithm