MCPcopy
hub / github.com/keon/algorithms / recur_insert

Method recur_insert

algorithms/data_structures/bst.py:70–84  ·  view source on GitHub ↗
(self, root, data)

Source from the content-addressed store, hash-verified

68 return True
69
70 def recur_insert(self, root, data):
71 if root.data == data: # The data is already there
72 return False
73 elif data < root.data: # Go to left root
74 if root.left: # If left root is a node
75 return self.recur_insert(root.left, data)
76 else: # left root is a None
77 root.left = Node(data)
78 return True
79 else: # Go to right root
80 if root.right: # If right root is a node
81 return self.recur_insert(root.right, data)
82 else:
83 root.right = Node(data)
84 return True
85
86 """
87 Preorder, Postorder, Inorder traversal bst

Callers 1

insertMethod · 0.95

Calls 1

NodeClass · 0.70

Tested by

no test coverage detected