Skip to content

Commit

Permalink
Merge pull request #35 from pypypraful/master
Browse files Browse the repository at this point in the history
SelectionSort.py created
  • Loading branch information
i-vishi authored Oct 2, 2018
2 parents 2bfbf5f + bd493aa commit 3a41d69
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sorting/Selection Sort/SelectionSort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Python program for implementation of Selection Sort
# This function takes list as input argument and return sorted list
def SelectionSort(A):
# 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]
return A

0 comments on commit 3a41d69

Please sign in to comment.