0
I am. Not getting the correct values... Pls check the problem
Avl tree Datastructure https://code.sololearn.com/ca9A14a8a0a1/?ref=app
5 Respuestas
+ 1
Aditya Salabh did you see what is happening? When the top node rotates, it is no longer the root. But the program continues to add nodes as if the original root were in place. The tree ends up unbalanced, and printing the tree from the old root fails to show the whole left side (6 and 9) because the old root is now a child node.
+ 1
Got it... Finally
0
The reason that it fails to print nodes 6 and 9 is due to the root pointing to the wrong node. When the rotate methods get called, check whether the root should get updated.
0
Brian not able to find it
0
Try this to see what I mean. Insert this code at line 46:
global root
if cur_node == root:
print ("The top node rotated right.")