Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #La función merge comienza con una comparación entre dos listas de
- #tamaño 1. Las listas sucesivas que recibe luego están ordenadas
- def merge(izq, der):
- lst_ord = []
- ind_izq = ind_der = 0
- while ind_izq < len(izq) and ind_der < len(der):
- if izq[ind_izq] <= der[ind_der]:
- lst_ord.append(izq[ind_izq])
- ind_izq += 1
- else:
- lst_ord.append(der[ind_der])
- ind_der += 1
- if ind_izq == len(izq):
- lst_ord.extend(der[ind_der:])
- else:
- lst_ord.extend(izq[ind_izq:])
- return lst_ord
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement