File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 11# Author: OMKAR PATHAK
2+ # Contributors: Mohamed Kiouaz
23# Created On: 31st July 2017
34
4- # Best O(n^2 ); Average O(n^2 ); Worst O(n^2)
5+ # Best O(n); Average O(n*(n-1)/4 ); Worst O(n^2)
56
67# Bubble Sorting algorithm
78def sort (List ):
89 for i in range (len (List )):
10+ stop = True
911 for j in range (len (List ) - 1 , i , - 1 ):
1012 if List [j ] < List [j - 1 ]:
13+ stop = False
1114 List [j ], List [j - 1 ] = List [j - 1 ], List [j ]
15+ if (stop == True ):
16+ return List
1217 return List
1318
1419# time complexities
1520def time_complexities ():
16- return '''Best Case: O(n ^ 2), Average Case: O(n ^ 2), Worst Case: O(n ^ 2)'''
21+ return '''Best case O(n); Average case O(n * (n - 1) / 4); Worst case O(n ^ 2)'''
1722
1823# easily retrieve the source code of the sort function
1924def get_code ():
You can’t perform that action at this time.
0 commit comments