Last active
November 3, 2015 07:01
-
-
Save rishi93/ca04ca9dcecb2fdb8850 to your computer and use it in GitHub Desktop.
Selection Sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selectionsort(arr): | |
for i in range(0,len(arr)): | |
min_index = i | |
for j in range(i+1,len(arr)): | |
if arr[j] < arr[min_index]: | |
min_index = j | |
arr[min_index],arr[i] = arr[i],arr[min_index] | |
print(arr) | |
arr = [4,3,1,6,2,5] | |
selectionsort(arr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment