return
    pits.append(node.pit)
    durs.append(0.5)
    preOrder(pits, durs, node.left)
    preOrder(pits, durs, node.right)
    return pits, durs

def postOrder(pits, durs, node):
    if node == None:
        return
    postOrder(pits, durs, node.left)
    postOrder(pits, durs, node.right)
    pits.append(node.pit)
    durs.append(0.25)
    return pits, durs

pitches = []
durs = []
ps,ds = inOrder([], [], a)
pitches.extend(ps)
durs.extend(ds)
ps,ds = preOrder([], [], a)
pitches.extend(ps)
durs.extend(ds)
ps,ds = postOrder([], [], a)
pitches.extend(ps)
durs.extend(ds)


mh.showLists(pitches, durs)
Ejemplo n.º 2
0
            j += 1
            durs.append(0.25)
    if i < len(x1):
        new_list.extend(x1[i:])
        pits.extend(x1[:i])
        durs.extend([0.5 for k in x1[:i]])
    elif j < len(x2):
        new_list.extend(x2[j:])
        pits.extend(x2[j:])
        durs.extend([0.5 for k in x2[:i]])
    return new_list

def mergeSort(list):
    if len(list) == 1:
        return list
    if len(list) >= 2:
        half_point = len(list)/2
        first_half = mergeSort(list[:half_point])
        second_half = mergeSort(list[half_point:])
        #pits.extend(first_half)
        #pits.extend(second_half)
        return merge(first_half, second_half)


a = mergeSort(nums)

pits.extend(a)
durs.extend([0.125 for i in a])

mh.showLists(pits, durs)