Created
February 26, 2018 22:03
-
-
Save lohxx/235ef82cc39a920b01a81ab05ae9921f to your computer and use it in GitHub Desktop.
This file contains 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 swap(min,max,arr): | |
arr[max],arr[min] = arr[min],arr[max] | |
return arr[max] | |
def bubble_sort(arr): | |
for i in range(len(arr)): | |
for j in range(len(arr)-1): | |
if arr[j] > arr[j+1]: | |
swap(j,j+1,arr) | |
print(arr) | |
bubble_sort([x for x in range(15,-1,-1)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment