Could not insert elements into Binary Search Tree in Python -
class node: def __init__(self,key): self.left=none self.right=none self.val=key def insert(root,key): if root none: root=node(key) else: if root.val < key: insert(root.right, key) else: insert(root.left, key) def inorder(root): if root: inorder(root.right) print root.val inorder(root.left) root=none d=input() while(d!=-1): insert(root,d) d=input() inorder(root)
i not print above tree elements inorder.....what wrong code....can explain?
Comments
Post a Comment