0 votes
115 views
in Python Programming (SBLC) by (420 points)
edited
write a program for selection sort in c & python

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
 def selection_sort(list):
    for i in range(0, len(list) - 1):
        smallest = i
        for j in range(i + 1, len(list)):
            if list[j] < list[smallest]:
                smallest = j
        list[i], list[smallest] = list[smallest], list[i]
list = input('enter the list').split()
list = [int(x) for x in list]
selection_sort(list)
print('Sorted list: ',list)

Related questions

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

563 users

...