atrifusion.py

Created by bilouclic

Created on December 16, 2024

715 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, i_Debut = 0, i_Fin = None) :
if i_Fin is None : i_Fin = len(tab) - 1
if i_Debut < i_Fin and i_Debut >=0 and i_Fin < len(tab) :
indice_Partage = (i_Debut + i_Fin - 1) // 2
tri_fusion( tab, i_Debut, indice_Partage)
tri_fusion( tab, indice_Partage + 1, i_Fin)
fusionner( tab, i_Debut, indice_Partage, i_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.