Created
January 8, 2020 21:22
-
-
Save pknowledge/471d81b8a2454317a0e488f879fed2c1 to your computer and use it in GitHub Desktop.
Python BubbleSort Sorting Algorithm | Python Data Structures and Algorithms
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
a=[2,23,14,7,32,39] | |
def bubbleSort(arr): | |
n=len(arr) | |
for i in range(n): | |
for j in range(n-1-i): | |
if arr[j]>arr[j+1]: | |
arr[j],arr[j+1]=arr[j+1],arr[j] | |
print(arr) | |
#print("The unosrted list is:") | |
#print(a) | |
bubbleSort(a) | |
#print("The sorted list is:") | |
#print(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment