Skip to content

Commit cd5ce5d

Browse files
committed
Bubble Sort Algorithm
1 parent fa51f76 commit cd5ce5d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
__author__ = 'Avinash'
2+
3+
4+
def bubble_sort(sort_list):
5+
for j in range(len(sort_list)):
6+
for k in range(len(sort_list) - 1):
7+
if sort_list[k] > sort_list[k + 1]:
8+
sort_list[k], sort_list[k + 1] = sort_list[k + 1], sort_list[k]
9+
print('\nThe sorted list: \t', sort_list)
10+
print('\n')
11+
12+
13+
lst = []
14+
size = int(input("\nEnter size of the list: \t"))
15+
16+
for i in range(size):
17+
elements = int(input("Enter the element: \t"))
18+
lst.append(elements)
19+
20+
bubble_sort(lst)

0 commit comments

Comments
 (0)