def fusion(lst1, lst2): n1 = len(lst1) n2 = len(lst2) lst12 = [0] * (n1 + n2) i1 = 0 # indice courant dans i2 = 0 # indice courant dans i = 0 # indice courant dans # Tant que le parcours de l lst2 # de lst2 puis on copie dans while i1 < n1 and i2 < n2 : if lst1[i1] < lst2[i2]: lst12[i] = lst1[i1] i1 = i1 + 1 else: lst12[i] = lst2[i2] i2 = i2 + 1 i += 1 # Tant que le parcours de la l while i1 < n1: lst12[i] = lst1[i1] i1 = i1 + 1 i = i + 1 # Tant que le parcours de la li while i2 < n2: lst12[i] = lst2[i2] i2 = i2 + 1 i = i + 1 return lst12 condensé : def fusion_2(tab1, tab2): t = [0] * (len(tab1) + len(tab2)) i, j = 0, 0 for k in range(len(t)): if i >= len(tab1) or (j < len(tab2) and tab1[i] > tab2[j]): t[k] = tab2[j] j = j + 1 else: t[k] = tab1[i] i = i + 1 return t