We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def insert(self, val):
if self.root is None:
self.root = Node(val)
else:
current = self.root
while True:
if val < current.info:
if current.left is None:
current.left = Node(val)
break
else:
current = current.left
else:
if current.right is None:
current.right = Node(val)
break
else:
current = current.right
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Insertion
You are viewing a single comment's thread. Return to all comments →