文章
1
粉丝
138
获赞
0
访问
9.4k
堆的遍历,构造一个完全二叉树,遍历堆。
def travel(x, deep, res): if deep == 6: print("".join(res)) return res[:-1] res.append(x[2*deep+1]) res = travel(x, deep+1, res) res.append(x[2*deep+2]) res = travel(x, deep+1, res) return res[:-1] if __name__ == '__main__': a = ["0", "1"] * 63 a = ["0"] + a travel(a, 0, [])
登录后发布评论
暂无评论,来抢沙发