Inserting an Element in a BST:

def insert(root,node):
    if root == None:
        root = node
    else:
        if node.data<root.data:
            if root.left == None:
                root.left = node
            else:
                insert(root.left,node)
        else:
            if root.right == None:
                root.right == node
            else:
                insert(root.right,node)

results matching ""

    No results matching ""