+2 votes
in Class 12 by kratos

Consider the following unsorted list:

99 78 25 48 51 11

Sort the list using selection sort algorithm. Show the status of the list after every iteration.

1 Answer

+5 votes
by kratos
 
Best answer

def selection_sort(DATA_LIST):

for i in range(0, len (DATA_LIST)):

min = i

for j in range(i + 1, len(DATA_LIST)):

if DATA_LIST[j] < DATA_LIST[min]:

min = j

swapping

temp= DATA_LIST[min]

DATA_LIST[min] = DATA_LIST[i]

DATA_LIST [i]=temp

print DATA_LIST

DATA_LIST = [99 78 25 48 51 11]

print “LIST BEFOR SORTING”,DATA_LIST

selection_sort(DATA_LIST)

...