Skip to content

Latest commit

 

History

History
 
 

SelectionSort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Selection Sort

Selection Sort is one among the 3 (others including Insertion Sort and Bubble Sort) comparison-based sorting algorithms. It has O(N^2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and it has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory(or external memory) is limited. Selection sort is based on Brute force method.

Approach:

  1. Find the smallest element in the array and exchange it with the element in the first position.
  2. Find the second smallest element in the array and exchange it with the element in the second position.
  3. Continue this process until the array is sorted.

Complexity

Name Best Average Worst Memory
Selection sort n2 n2 n2 1

Animation to represent the working of selection sort

Algorithm Visualization

For Visualizations on how selection sort works