r/computerscience • u/Careless_Schedule149 • May 18 '25
Help I need help understanding avl trees for my data structures final tomorrow
I have been trying to study avl trees for my final and I keep running into to conflicting height calculations. I am going to provide a few pictures of what my professor is doing because I can’t understand what she is doing. I understand it that the balance factor is height of left subtree - height of right subtree. And the height of a subtree is the number of edges to a leaf node. I’m pretty sure I understand how rotations work but whenever I try to practice the balance factor is always off and I don’t know which is which because my professor seems like she is doing 2 different height calculations.
Also if anyone has any resources to practice avl trees and their rotations
Thank you for any and all h!







4
u/Necessary_Housing466 May 18 '25
https://www.youtube.com/watch?v=zP2xbKerIds
https://www.youtube.com/watch?v=vRwi_UcZGjU
those are videos for rotations, i learned from the second one.
you can use this webpage to see the rotations for a given example
https://www.cs.usfca.edu/~galles/visualization/AVLtree.html
1
u/viewless_pond May 18 '25
Can you give an example where you do the rotation and the balance comes out wrong? That could show us what exactly you do not understand. Or show us an example where you think two different heights are being used.
1
u/[deleted] May 18 '25
Types of Trees in DS
1
u/TheologyFan May 18 '25
https://csvistool.com/AVL