Ejemplo n.º 1
0
def vistree(heaparray):

    n = len(heaparray)
    printstr = '{'

    for i in range(n - 1):
        if (int(heaparray[i]) >= 0):
            printstr += str(heaparray[i]) + ','
        else:
            printstr += '#' + ','
    if (int(heaparray[n - 1]) >= 0):
        printstr += str(heaparray[n - 1])
    else:
        printstr += '#'
    printstr += '}'

    draw_level_order(printstr)
Ejemplo n.º 2
0
def vistree2(treesimple):
    n = treesimple.n
    if (n < 1):
        print("There is no heap")
        return
    printstr = '{'

    for i in range(n - 1):
        if (int(treesimple.arr[i]) >= 0):
            printstr += str(treesimple.arr[i]) + ','
        else:
            printstr += '#' + ','
    if (int(treesimple.arr[n - 1]) >= 0):
        printstr += str(treesimple.arr[n - 1])
    else:
        printstr += '#'
    printstr += '}'

    draw_level_order(printstr)