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.
2 parents 469a07c + 191f94c commit deb5d18Copy full SHA for deb5d18
Selectionsort.py
@@ -0,0 +1,21 @@
1
+import sys
2
+A = [64, 25, 12, 22, 11]
3
+
4
+# Traverse through all array elements
5
+for i in range(len(A)):
6
7
+ # Find the minimum element in remaining
8
+ # unsorted array
9
+ min_idx = i
10
+ for j in range(i+1, len(A)):
11
+ if A[min_idx] > A[j]:
12
+ min_idx = j
13
14
+ # Swap the found minimum element with
15
+ # the first element
16
+ A[i], A[min_idx] = A[min_idx], A[i]
17
18
+# Driver code to test above
19
+print ("Sorted array")
20
21
+ print("%d" %A[i]),
0 commit comments