Advertisement
MiguelazoDS

Untitled

Sep 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #La función merge comienza con una comparación entre dos listas de
  2. #tamaño 1. Las listas sucesivas que recibe luego están ordenadas
  3. def merge(izq, der):
  4.     lst_ord = []
  5.     ind_izq = ind_der = 0
  6.     while ind_izq < len(izq) and ind_der < len(der):
  7.         if izq[ind_izq] <= der[ind_der]:
  8.             lst_ord.append(izq[ind_izq])
  9.             ind_izq += 1
  10.         else:
  11.             lst_ord.append(der[ind_der])
  12.             ind_der += 1
  13.     if ind_izq == len(izq):
  14.         lst_ord.extend(der[ind_der:])
  15.     else:
  16.         lst_ord.extend(izq[ind_izq:])
  17.     return lst_ord
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement