Skip to content

Instantly share code, notes, and snippets.

@dheshanm
Created December 13, 2017 08:32
Show Gist options
  • Save dheshanm/c493d47c1ef7fc83cff414050d7133e6 to your computer and use it in GitHub Desktop.
Save dheshanm/c493d47c1ef7fc83cff414050d7133e6 to your computer and use it in GitHub Desktop.
procedure selection sort
list : array of items
n : size of list
for i = 1 to n - 1
/* set current element as minimum*/
min = i
/* check the element to be minimum */
for j = i+1 to n
if list[j] < list[min] then
min = j;
end if
end for
/* swap the minimum element with the current element*/
if indexMin != i then
swap list[min] and list[i]
end if
end for
end procedure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment