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 1fba78e

Browse files
author
Amogh Singhal
authored
Create bubble_sort.py
1 parent 323437c commit 1fba78e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎bubble_sort.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# A simple implementation of bubble sort
2+
3+
def bubbleSort(arr):
4+
for i in range(len(arr)):
5+
for j in range(i+1, len(arr)):
6+
if arr[i] > arr[j]:
7+
arr[i], arr[j] = arr[j], arr[i]
8+
9+
return arr
10+
11+
arr = [2, 6, 1, 5, 3, 4]
12+
res = bubbleSort(arr)
13+
print(res)

0 commit comments

Comments
(0)

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