MCPcopy Create free account
hub / github.com/careercup/ctci / addUsingKey

Method addUsingKey

python/Chapter 4/Question4_5/ChapQ4.5.py:68–85  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

66 self.root = None
67
68 def addUsingKey(self, key):
69 treenode = TreeNode(key)
70 if self.root == None:
71 self.root = treenode
72 else:
73 buff = self.root
74 current =self.root
75 while current != None:
76 if current.key < treenode.key:
77 buff = current
78 current = current.right
79 else:
80 buff = current
81 current = current.left
82 if buff.key < treenode.key:
83 buff.right = treenode
84 else:
85 buff.left = treenode
86# min/max solution
87def checkBST(root,mini,maxi):
88 if root == None:

Callers 1

ChapQ4.5.pyFile · 0.45

Calls 1

TreeNodeClass · 0.70

Tested by

no test coverage detected