Selection Sort
Selection Sort
As of now, we have a rough understanding of the selection sort. Let us now have a look at the
algorithm followed by the code for a better understanding:
Python Program
As discussed above in the algorithm, let us now dive into the programming part of the
Selection Sort operation influenced by the algorithm. In this program user can input the list
by giving whitespace in the console part:
def Selection_Sort(array):
for i in range(0, len(array) - 1):
smallest = i
for j in range(i + 1, len(array)):
if array[j] < array[smallest]:
smallest = j
array[i], array[smallest] = array[smallest], array[i]