File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
chapters/sorting_searching/bubble/code/python Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,5 @@ Nicole Mazzuca
3
3
Marius Becker
4
4
Gathros
5
5
Jeremie Gillet (- Jie -)
6
- Salim Khatib
6
+ Salim Khatib
7
+ Hitesh C
Original file line number Diff line number Diff line change
1
+ #!usr/bin/python3
2
+
3
+ #import section
4
+ import random
5
+
6
+
7
+ def bubble_sort (array ):
8
+ len_array = len (array )
9
+ for i in range (len_array ):
10
+ for j in range (len_array - i - 1 ):
11
+ if (array [j ] > array [j + 1 ]):
12
+ array [j ], array [j + 1 ] = array [j + 1 ], array [j ] #swap elements in the list
13
+
14
+
15
+ def main ():
16
+ number = [random .randint (0 , 10000 ) for _ in range (10 )]
17
+ print ("Before Sorting {}" .format (number ))
18
+ bubble_sort (number )
19
+ print ("After Sorting {}" .format (number ))
20
+
21
+
22
+ if __name__ == "__main__" :
23
+ main ()
You can’t perform that action at this time.
0 commit comments