Created
March 15, 2021 20:22
-
-
Save anonymousmaharaj/efef6090c52ba8888b4f3a291a13aa55 to your computer and use it in GitHub Desktop.
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
import main | |
def findsmaller(arr): | |
smallest = arr[0] | |
smallest_index = 0 | |
for i in range(1,len(arr)): | |
if arr[i]< smallest: | |
smallest=arr[i] | |
smallest_index = i | |
return smallest_index | |
def selectionSort(arr): | |
newArr = [] | |
for i in range(len(arr)): | |
smallest = findsmaller(arr) | |
newArr.append(arr.pop(smallest)) | |
return newArr | |
list = [3,5,1,5,7 ,8 ,9 ,3 ,4 ,5,0,-3] | |
print(selectionSort(list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment