用列表创建二叉树,用python代码实现

使用Python代码创建二叉树的一种常用方法是使用列表:class Node: def init(self, val): self.val = val self.left = None self.right = None# Function to create a binary tree from the given array def createBinaryTree(arr, root, i, n):

if i < n: 
    temp = Node(arr[i])  
    root

猜你喜欢

转载自blog.csdn.net/weixin_42601547/article/details/129553641