Skip to content

Instantly share code, notes, and snippets.

@jigi-33
Created May 26, 2020 11:03
Show Gist options
  • Save jigi-33/0838e26fab1447028d4ce735db5822e9 to your computer and use it in GitHub Desktop.
Save jigi-33/0838e26fab1447028d4ce735db5822e9 to your computer and use it in GitHub Desktop.
Сортировка пузырьком от geeks-to-geeks
# Implementation of Bubble Sorting (from geeks-to-geeks):
def bubble_sort(arr):
n = len(arr)
for i in range(n-1):
for j in range(0, n-i-1):
# Swap if the element found is greater, than the next element
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
arr = [64, 34, 25, 12, 22, 11, 90]
bubble_sort(arr)
print ("Sorted array is:")
for i in range(len(arr)):
print ("%d" %arr[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment