Skip to content

Commit

Permalink
Create selectionsort.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraUnicorn74 authored Oct 16, 2019
1 parent 967f5a1 commit 686cf0f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions selection_sort/python/selectionsort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Python program for implementation of Selection
# Sort
import sys
A = [64, 25, 12, 22, 11]

# Traverse through all array elements
for i in range(len(A)):

# Find the minimum element in remaining
# unsorted array
min_idx = i
for j in range(i+1, len(A)):
if A[min_idx] > A[j]:
min_idx = j

# Swap the found minimum element with
# the first element
A[i], A[min_idx] = A[min_idx], A[i]

# Driver code to test above
print ("Sorted array")
for i in range(len(A)):
print("%d" %A[i]),

0 comments on commit 686cf0f

Please sign in to comment.