We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c123e05 commit 38a488cCopy full SHA for 38a488c
Algorithms/Sorting Algorithms/selection_sort.py
@@ -0,0 +1,21 @@
1
+__author__ = 'Avinash'
2
+
3
4
+def selection_sort(sort_list):
5
+ for j in range(len(sort_list)):
6
+ smallest_element = min(sort_list[j:])
7
+ index = sort_list.index(smallest_element)
8
+ sort_list[j], sort_list[index] = sort_list[index], sort_list[j]
9
+ print("\nPASS", j, sort_list)
10
+ print('\n\nThe sorted list: \t', sort_list)
11
+ print('\n')
12
13
14
+lst = []
15
+size = int(input("Enter size of the list: "))
16
17
+for i in range(size):
18
+ elements = int(input("Enter an element"))
19
+ lst.append(elements)
20
21
+selection_sort(lst)
0 commit comments