formatte file

This commit is contained in:
2025-04-01 14:28:43 +02:00
parent f2ae2cbc13
commit e03e5458aa
77 changed files with 1231 additions and 945 deletions

View File

@@ -8,9 +8,10 @@ def partition(tab, debut, fin):
tab[i + 1], tab[fin] = tab[fin], tab[i + 1]
return i + 1
def fusion(tab, debut, milieu, fin):
gauche = tab[debut:milieu + 1]
droite = tab[milieu + 1:fin + 1]
gauche = tab[debut : milieu + 1]
droite = tab[milieu + 1 : fin + 1]
i, j, k = 0, 0, debut
while i < len(gauche) and j < len(droite):
@@ -32,6 +33,7 @@ def fusion(tab, debut, milieu, fin):
j += 1
k += 1
def tri_fusion_partition(tab, debut, fin):
if debut < fin:
pivot_index = partition(tab, debut, fin)
@@ -39,7 +41,7 @@ def tri_fusion_partition(tab, debut, fin):
tri_fusion_partition(tab, pivot_index + 1, fin)
fusion(tab, debut, pivot_index, fin)
tableau = [34, 7, 23, 32, 5, 62, 32, 8, 9]
tri_fusion_partition(tableau, 0, len(tableau) - 1)
print("Tableau trié :", tableau)