Created
May 26, 2020 11:03
-
-
Save jigi-33/0838e26fab1447028d4ce735db5822e9 to your computer and use it in GitHub Desktop.
Сортировка пузырьком от geeks-to-geeks
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
# 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