cours_progra/q1/17nov/ex5.py
2023-02-15 13:40:50 +01:00

26 lines
691 B
Python

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()