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 a702455 commit 18e8f0fCopy full SHA for 18e8f0f
selectionsort.py
@@ -0,0 +1,20 @@
1
+from generator import Generator
2
+
3
4
+def SelectionSort(arr: list) -> list:
5
+ for i in range(len(arr)):
6
+ min_i = i # minimum element in remaining unsorted array
7
+ for j in range(i + 1, len(arr)):
8
+ if arr[min_i] > arr[j]:
9
+ min_i = j
10
11
+ # Swap the minimum element with the first element
12
+ arr[i], arr[min_i] = arr[min_i], arr[i]
13
14
+ return arr
15
16
17
+if __name__ == '__main__':
18
+ arr = Generator(1000)
19
+ sorted_list = SelectionSort(arr)
20
+ print(sorted_list)
0 commit comments