"Coding is just like talking to a unknown girl. Once you talked to her with guts, the next time you'll never afraid",Really? Yes , try it Now !!!
Everything here is for education and learning purpose only , individual holds rights on outer posts/links etc.
Team Cracking The Code
Assuming that every node has parent pointer, we can perform left or right rotation(depending on whether the node is right or left child)until we reach the root.
2 comments :
Assuming that every node has parent pointer, we can perform left or right rotation(depending on whether the node is right or left child)until we reach the root.
Is this correct?
Perform an inorder traversal and find the given node in it and keep the given node as root and insert the nodes to it in the given inorder traversal.
This will take O(N log N)
I believe there will be a better solution similar to AVL Tree rotation
Post a Comment