We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9222b6c commit c3f47d4Copy full SHA for c3f47d4
1 file changed
DataStructures/Section10/BubbleSort.py
@@ -0,0 +1,22 @@
1
+#Buuble Sort
2
+
3
+def bubble_sort(unordered_list):
4
+ iteration_number = len(unordered_list) - 1
5
+ for i in range(iteration_number, 0, -1):
6
+ for j in range(i):
7
+ if unordered_list [j] > unordered_list[j + 1]:
8
+ temp = unordered_list[j]
9
+ unordered_list[j] = unordered_list[j + 1]
10
+ unordered_list[j + 1] = temp
11
12
13
+print("-----Bubble Sort Outputs-----\n")
14
+my_list = [4,3,2,1]
15
+bubble_sort(my_list)
16
+print(my_list, '\n')
17
18
+my_list = [1,12,3,4]
19
20
+print(my_list)
21
22
0 commit comments