Selection Sort
Definition:
Selection sort is a simple comparison-based sorting algorithm that repeatedly selects the smallest (or largest) element from the unsorted portion of the array and swaps it with the first unsorted element. It works by dividing the array into a sorted and an unsorted region and systematically reducing the size of the unsorted region.
Video Explanation

Characteristics:
-
In-Place Sorting:
- Selection sort operates directly on the input array and does not require additional storage, making it an in-place sorting algorithm.
-
Not Stable:
- Selection sort is not a stable sorting algorithm because equal elements can be swapped, potentially changing their relative order.
-
Selection Process:
- In each pass, the algorithm selects the smallest element from the unsorted part of the array and places it in the correct position by swapping it with the first element of the unsorted part.
-
Inefficient for Large Datasets:
- Although the algorithm is simple, it is not efficient for large datasets as it requires many comparisons and swaps.