Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
631 B
2
Indexable
Never
a = [89, 7, 9, 6, 11,0]
b = [5,9,12,14,16]
c = []

def mergesort(arr):

    if len(arr) <= 1:
        return arr
    
    mid = len(arr) // 2

    a = mergesort(arr[:mid])
    b = mergesort(arr[mid:])
    c = []

    while len(a) > 0 and len(b) > 0:
        if (a[0] < b[0]):
            tmp = a[0]
            a.remove(tmp)
            if len(c) == 0 or tmp != c[len(c) - 1]:
                c.append(tmp)
        else:
            tmp = a[0]
            a.remove(tmp)
            if len(c) == 0 or tmp != c[len(c) - 1]:
                c.append(tmp)
    
    return a + b + c

print(mergesort(a + b))