MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / spliceOut

Method spliceOut

BinarySearchTree.py:126–144  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

124 self.delete(key)
125
126 def spliceOut(self):
127 if self.isLeaf():
128 if self.isLeftChild():
129 self.parent.leftChild = None
130 else:
131 self.parent.rightChild = None
132 elif self.hasAnyChildren():
133 if self.hasLeftChild():
134 if self.isLeftChild():
135 self.parent.leftChild = self.leftChild
136 else:
137 self.parent.rightChild = self.leftChild
138 self.leftChild.parent = self.parent
139 else:
140 if self.isLeftChild():
141 self.parent.leftChild = self.rightChild
142 else:
143 self.parent.rightChild = self.rightChild
144 self.rightChild.parent = self.parent
145
146 def findSuccessor(self):
147 succ = None

Callers 1

removeMethod · 0.45

Calls 4

isLeafMethod · 0.45
isLeftChildMethod · 0.45
hasAnyChildrenMethod · 0.45
hasLeftChildMethod · 0.45

Tested by

no test coverage detected