MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / updateBalance

Method updateBalance

AVL.py:79–90  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

77 self.updateBalance(currentNode.rightChild)
78
79 def updateBalance(self, node):
80 if node.balanceFactor > 1 or node.balanceFactor < -1:
81 self.rebalance(node)
82 return
83 if node.parent != None:
84 if node.isLeftChild():
85 node.parent.balanceFactor += 1
86 elif node.isRightChild():
87 node.parent.balanceFactor -= 1
88
89 if node.parent.balanceFactor != 0:
90 self.updateBalance(node.parent)
91
92 def rotateLeft(self, rotRoot):
93 newRoot = rotRoot.rightChild

Callers 1

_putMethod · 0.95

Calls 3

rebalanceMethod · 0.95
isLeftChildMethod · 0.45
isRightChildMethod · 0.45

Tested by

no test coverage detected