HWANGYUKAH 2020-04-26 10:24 采纳率: 0%
浏览 113

python 创建一个二叉树,无法运行,求助!!

打算生成一个节点,运行出错,向大佬们求助

class binaryTree():

    def node(root):
        return [root,[],[]]

    def insert_left(root,new_branch):
        t = root.pop(1)
        if len(t)>1:
            root.insert(1,[new_branch,t,[]])
        else:
            root.insert(1,[new_branch,[],[]])
        return root
    def insert_right(root,new_branch):
        t = root.pop(2)
        if len(t)>1:
            root.insert(2,[new_branch,[],t])
        else:
            root.insert(2,[new_branch,[],[]])
        return root

    def get_root_val(root):
        return root[0]
    def seet_root_val(root,new_val):
        root[0] = new_val
    def get_left_val(root):
        return root[1]
    def get_right_child(root):
        return root[2]]

打算生成一个节点

bi = binaryTree().node('a')
print(bi)

图片说明

运行出错,向大佬们求助

  • 写回答

2条回答 默认 最新

  • 成仙 2020-04-26 10:41
    关注

    是不是传入的参数有问题

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集