MCPcopy Index your code
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / _put

Method _put

AVL.py:65–77  ·  view source on GitHub ↗
(self, key, val, currentNode)

Source from the content-addressed store, hash-verified

63 self.size = self.size + 1
64
65 def _put(self, key, val, currentNode):
66 if key < currentNode.key:
67 if currentNode.hasLeftChild():
68 self._put(key, val, currentNode.leftChild)
69 else:
70 currentNode.leftChild = TreeNode(key, val, parent=currentNode)
71 self.updateBalance(currentNode.leftChild)
72 else:
73 if currentNode.hasRightChild():
74 self._put(key, val, currentNode.rightChild)
75 else:
76 currentNode.rightChild = TreeNode(key, val, parent=currentNode)
77 self.updateBalance(currentNode.rightChild)
78
79 def updateBalance(self, node):
80 if node.balanceFactor > 1 or node.balanceFactor < -1:

Callers 1

putMethod · 0.95

Calls 4

updateBalanceMethod · 0.95
TreeNodeClass · 0.70
hasLeftChildMethod · 0.45
hasRightChildMethod · 0.45

Tested by

no test coverage detected