Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 29, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/babc371bdaee30259677ca52230392c2 to your computer and use it in GitHub Desktop.
Save amankharwal/babc371bdaee30259677ca52230392c2 to your computer and use it in GitHub Desktop.
def bubble_sort(array):
n = len(array)
for i in range(n):
for j in range(0, n-i-1):
if array[j] > array[j+1]:
array[j], array[j+1] = array[j+1], array[j]
array = [64, 56, 78, 34, 98, 32, 67]
bubble_sort(array)
print("Sorted array using Bubble Sort Algorithm : ")
for i in range(len(array)):
print(array[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment