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

Method addUsingKey

python/Chapter 4/Question4_8/ChapQ4.8.py:126–145  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

124 self.root = None
125
126 def addUsingKey(self, key):
127 treenode = TreeNode(key)
128 if self.root == None:
129 self.root = treenode
130 else:
131 buff = self.root
132 current =self.root
133 while current != None:
134 if current.key < treenode.key:
135 buff = current
136 current = current.right
137 else:
138 buff = current
139 current = current.left
140 if buff.key < treenode.key:
141 buff.right = treenode
142 treenode.p = buff
143 else:
144 buff.left = treenode
145 treenode.p = buff
146
147def isInc(r1, r2):
148 if r2 == None:

Callers 1

ChapQ4.8.pyFile · 0.45

Calls 1

TreeNodeClass · 0.70

Tested by

no test coverage detected