@@ -0,0 +1,997 @@
+# insert a element to BST..guarantee that it doesn't already exist%0A# there are many possible valid answers%0A# we will try to take it to the leaf and ofcourse still maintain BST property%0A%0Aclass Node:%0A    def __init__(self, val):%0A        self.val = val%0A        self.left = None%0A        self.right = None%0A%0Adef inorder_recu(root):%0A    if root:%0A        inorder_recu(root.left)%0A        print(root.val)%0A        inorder_recu(root.right)%0A%0Adef insert_to_BST(node, num):%0A    if not node:%0A        return Node(num)%0A    if node.val %3C num:%0A        node.right = insert_to_BST(node.right, num)%0A    if num %3C node.val:%0A        node.left = insert_to_BST(node.left, num)%0A    return node%0A%0A%0A'''%0A           5%0A             %0A        4      6%0A               %0A      3          7%0A     %0A    1%0A'''%0Atree = Node(5)%0Atree.left = Node(4)%0Atree.right = Node(6)%0Atree.left.left = Node(3)%0Atree.left.left.left = Node(1)%0Atree.right.right = Node(7)%0Aprint('Before')%0Ainorder_recu(tree)%0Ainsert_to_BST(tree, 5.5)%0Aprint('After')%0Ainorder_recu(tree)

insert number to BST