Skip to content

Commit 2b62b42

Browse files
committed
Sorting
1 parent 2bc1047 commit 2b62b42

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sorting/BubbleSort.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def bubblesort(A):
2+
n = len(A)
3+
for passes in range(n-1,0,-1):
4+
for i in range(passes):
5+
if A[i] > A[i+1]:
6+
temp = A[i]
7+
A[i] = A[i+1]
8+
A[i+1] = temp
9+
10+
11+
A = [3, 5, 8, 9, 6, 2]
12+
print('Original Array:',A)
13+
bubblesort(A)
14+
print('Sorted Array:',A)

0 commit comments

Comments
 (0)