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 212e161 commit ded6c69Copy full SHA for ded6c69
selection_sort.py
@@ -0,0 +1,19 @@
1
+# A simple implementation of Selection Sort
2
+
3
+def selectionSort(arr):
4
+ i = 0
5
+ while i < len(arr):
6
+ min_index = i
7
+ for j in range(i+1, len(arr)):
8
+ if arr[j] < arr[min_index]:
9
+ min_index = j
10
11
+ arr[i], arr[min_index] = arr[min_index], arr[i]
12
+ i = i + 1
13
14
+ return arr
15
16
+arr = [2, 6, 1, 5, 3, 4]
17
+res = selectionSort(arr)
18
+print(res)
19
0 commit comments