1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
import time
import numpy as np
tab = np.random.randint(1,10,10)
def tri_selection(tab):
for i in range(len(tab)):
min = i
for j in range(i+1, len(tab)):
if tab[min] > tab[j]:
min = j
tmp = tab[i]
tab[i] = tab[min]
tab[min] = tmp
return tab
def time_(tab):
start_time = time.time()
print ("Le tableau trié est:")
tri_selection(tab)
end=time.time()
print(tab)
print("Temps d execution : %s secondes ---" % (end - start_time))
x= [100,200,300,400,500]
y= [time(tab)for tab in x]
from matplotlib.pyplot import plot
plot(x,y) |
Partager