📜  将列表转换为树 python 代码示例

📅  最后修改于: 2022-03-11 14:46:40.328000             🧑  作者: Mango

代码示例1
def normalize(tree, row=0, col=0):
    try:
        node = tree[row][col]
        left  = normalize(tree, row+1, col*2)
        right = normalize(tree, row+1, col*2+1)
        return [node, left, right] if left or right else [node]
    except:
        return None # child index does not exist