Skip to content

Commit 1a760e9

Browse files
authored
Create Bubble Sort Algorithm in Python
1 parent e9e7c96 commit 1a760e9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
a = [10,7,100,60,3,89]
2+
def bSort(a):
3+
n = len(a)
4+
for i in range(n-1):
5+
for j in range(n-i-1):
6+
if a[j] > a[j+1]:
7+
# Swaping elements
8+
a[j], a[j+1] = a[j+1], a[j]
9+
10+
bSort(a)
11+
print("Sorted array is:")
12+
print(a)

0 commit comments

Comments
 (0)