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

Method addUsingKey

python/Chapter 4/Question4_6/ChapQ4.6.py:83–102  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

81 self.root = None
82
83 def addUsingKey(self, key):
84 treenode = TreeNode(key)
85 if self.root == None:
86 self.root = treenode
87 else:
88 buff = self.root
89 current =self.root
90 while current != None:
91 if current.key < treenode.key:
92 buff = current
93 current = current.right
94 else:
95 buff = current
96 current = current.left
97 if buff.key < treenode.key:
98 buff.right = treenode
99 treenode.p = buff
100 else:
101 buff.left = treenode
102 treenode.p = buff
103
104def inorderSucc(treenode):
105 if treenode != None:

Callers 1

ChapQ4.6.pyFile · 0.45

Calls 1

TreeNodeClass · 0.70

Tested by

no test coverage detected