afusionregn.py

Created by bilouclic

Created on December 15, 2024

800 Bytes


def fusionner(tab, indice_Debut, indice_Partage, indice_Fin):
tab1 = [tab[i] for i in range
(indice_Debut, indice_Partage+1)]
tab2 = [tab[i] for i in range
(indice_Partage+1, indice_Fin+1)]
i, j = 0, 0
for k in range(indice_Debut, indice_Fin+1):
if i >= len(tab1) 
or (j < len(tab2) 
and tab1[i] > tab2[j]):
tab[k] = tab2[j]
j = j + 1
else:
tab[k] = tab1[i]
i = i + 1

def tri_fusion(tab, indice_Debut, indice_Fin):
""" trie par fusion la liste en 
paramètre depuis i_debut jusqu’à
i_fin """
if indice_Debut < indice_Fin 
and indice_Debut >= 0 
and indice_Fin < len(tab):
indice_Partage = 
(indice_Debut + indice_Fin - 1)
// 2
tri_fusion(tab, indice_Debut,
indice_Partage)
tri_fusion(tab, indice_Partage
+ 1, indice_Fin)
fusionner(tab, indice_Debut, 
indice_Partage, indice_Fin)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.