About Selection Sort
Selection Sort is one of the simplest sorting algorithms. It works by repeatedly finding the minimum element from the unsorted portion of the array and placing it at the beginning. The sorted portion grows from left to right with each iteration.
Core Concepts
- Comparison-based: Compares elements to find minimum
- In-place: Requires O(1) additional space
- Not stable: May change relative order of equal elements
- Time Complexity: O(n²) in all cases (no best case improvement)
- Best for: Small datasets, minimal memory, when memory writes are expensive
Selection Sort is known for making very few swaps compared to other O(n²) algorithms, making it useful when write operations are costly.
Visualization
Pseudocode
Algorithm
Statistics
- Comparisons: 0
- Swaps: 0
- Operations: 0