We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
There was an error while loading. Please reload this page.
1 parent 03a4251 commit 7a451a1Copy full SHA for 7a451a1
sorts/Selection Sort
@@ -0,0 +1,21 @@
1
+def selectionSort(array, size):
2
+
3
+ for s in range(size):
4
+ min_idx = s
5
6
+ for i in range(s + 1, size):
7
8
+ # For sorting in descending order
9
+ # for minimum element in each loop
10
+ if array[i] < array[min_idx]:
11
+ min_idx = i
12
13
+ # Arranging min at the correct position
14
+ (array[s], array[min_idx]) = (array[min_idx], array[s])
15
16
+data = [ 7, 2, 1, 6 ]
17
+size = len(data)
18
+selectionSort(data, size)
19
20
+print('Sorted Array in Ascending Order is :')
21
+print(data)
0 commit comments