.
This commit is contained in:
25
bac1/q1/17nov/ex5.py
Normal file
25
bac1/q1/17nov/ex5.py
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
def bubble_sort(liste:list):
|
||||
"""Sort the list with bubble sort inline """
|
||||
Order = False
|
||||
while not Order:
|
||||
Order = True
|
||||
for i in range(len(liste)-1):
|
||||
if liste[i] > liste[i+1]:
|
||||
liste[i], liste[i+1] = liste[i+1], liste[i]
|
||||
Order = False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from random import shuffle
|
||||
|
||||
from displayCpu import CpuPlot
|
||||
from umons_cpu import cpu_time
|
||||
from sort import dicho_search, insertion_sort, merge_sort, selection_sort
|
||||
|
||||
test_bubble = [cpu_time(bubble_sort, [i for i in range(j)]) for j in range(10)]
|
||||
|
||||
graph = CpuPlot(list(range(10)))
|
||||
graph.prepare(test_bubble)
|
||||
graph.draw()
|
||||
|
Reference in New Issue
Block a user