二进制搜索树插入方法不起作用

时间:2017-12-07 22:41:09

标签: python data-structures binary-search-tree

class Node:
    def __init__(self,value = None):
        self.value = value
        self.left = None
        self.right = None

class binary_search_tree:
    def __init__(self):
        self.root = None

    def insert(self,current,value):
        if current == None:
            current = Node(value)
        elif value < current.value:
            self.insert(current.left,value)
        elif value > current.value:
            self.insert(current.right,value)

tree = binary_search_tree()
for i in (12,5,18,3,4,6):
    tree.insert(tree.root,i)

我的二分查找树的插入方法不起作用,有人可以帮助我。

(帖子主要是代码,请添加更多详细信息。)

0 个答案:

没有答案