We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ccfd4c commit bb7778bCopy full SHA for bb7778b
selectionsort.py
@@ -0,0 +1,23 @@
1
+# Python program for implementation of Selection
2
+# Sort
3
+import sys
4
+A = [64, 25, 12, 22, 11]
5
+
6
+# Traverse through all array elements
7
+for i in range(len(A)):
8
9
+ # Find the minimum element in remaining
10
+ # unsorted array
11
+ min_idx = i
12
+ for j in range(i+1, len(A)):
13
+ if A[min_idx] > A[j]:
14
+ min_idx = j
15
16
+ # Swap the found minimum element with
17
+ # the first element
18
+ A[i], A[min_idx] = A[min_idx], A[i]
19
20
+# Driver code to test above
21
+print ("Sorted array")
22
23
+ print("%d" %A[i]),
0 commit comments