Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb44b78

Browse files
authored
feat: add bubble sort in Python (#812)
1 parent 1f93c2d commit bb44b78

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def bubbleSort(arr):
2+
n = len(arr)
3+
# Iterate over all array elements
4+
for i in range(n):
5+
# Last i elements are already in place
6+
for j in range(n - i - 1):
7+
if arr[j] > arr[j + 1]:
8+
arr[j], arr[j + 1] = arr[j + 1], arr[j]
9+
10+
11+
arr = [64, 34, 25, 12, 22, 11, 90]
12+
bubbleSort(arr)
13+
print(arr)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /