Answer the question
In order to leave comments, you need to log in
How to recalculate heights in avl tree?
When adding a new node, I calculate the heights like this:
def setHg(self,current):
current.height += 1
if(current.parent != None):
self.setHg(current.parent)
(root: 1, height: 3) -> (2, h: 2) -> (3, h: 1)
(1, h: 3) <- (root : 2, h: 2) -> (3, h: 1)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question