I am building a binary search tree, and I want to update the imbalance when I add a child and use this function in the add_child function.
But now I have met some problem, can someone tell me where is wrong? Thank you very much!
And it is correct to use it in the add_child function, if add_child, self.imbalance()
def update_imbalance(self) -> int:
self.imbalance += abs(self.right_child.value-self.left_child.value)
**the error: def update_imbalance(self) -> int:
self.imbalance += abs(self.right_child.value-self.left_child.value)
E AttributeError: 'NoneType' object has no attribute 'value' Node.py:51: AttributeError**