Selection Sort

The following is the basic code of Selection Sort algorithm:-
def selectionSort(l):
  for i in range(len(l)):
    minpos=i
    for j in range(i,len(l)):
      if l[j]<l[minpos]:
        minpos=j
    (l[i],l[minpos])=(l[minpos],l[i])
       
  return l
        

Comments

Popular posts from this blog

Prime partitioning a number

Rotating a list

Alternating prime and square