Skip to content

Latest commit

 

History

History

SelectionSort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Algorithm

selectionSort(array, n):
    for i = 1 -> n-1:
        min_index = i
        for j = i+1 -> n:
            if (array[j] < array[min_index]):
                min_index = j
    swap(array[i], array[min_index])

Complexity

  • Time:
    • Worst Case: formula
    • Average Case: formula
    • Best Case: formula
  • Space:
    • Worst Case: formula