Selection Sort
Selection Sort is a simple comparison-based sorting algorithm. It works by dividing the input list into two parts: a sorted sublist and an unsorted sublist. The algorithm repeatedly finds the minimum element from the unsorted sublist and moves it to the end of the sorted sublist.
Steps:
- Set the first element as the minimum
- Compare this with the remaining elements to find the actual minimum
- Swap the minimum with the first element
- Move to the next element and repeat until the array is sorted
Time Complexity
Best: O(n²)
Average: O(n²)
Worst: O(n²)
Space Complexity
O(1)
Array length:
7
Speed: