2

Just trying to figure out balancing in a AVL tree. My textbook does not cover AVL Trees, so I've just been googling information.

I can't quite grasp the rotating methods. Can anyone with more knowledge on the topic care to enlighten me?

Thanks.

LearningCS
  • 21
  • 1
  • The difference in depth between 2 external nodes between 2 branches must be AT MOST 1. If it is not, the tree will rearrange the nodes to balance. Take a look here for some examples: http://www.cise.ufl.edu/~nemo/cop3530/AVL-Tree-Rotations.pdf – Michael Aug 10 '16 at 20:59
  • Thanks Micheal, that was a great read. I now understand the rotations. Now, if I wanted to implement a insert method for an AVL tree. Would I use my insert method for a Binary Tree and just add code that will also check the balancing(rotating)? – LearningCS Aug 10 '16 at 21:18
  • possible duplicate of http://stackoverflow.com/questions/2004351/avl-tree-balancing – JavaHopper Aug 11 '16 at 00:06

0 Answers0