AVL tree rotation in Java

前端 未结 3 708
Happy的楠姐
Happy的楠姐 2021-02-06 18:00

I want to implement the Java AVL tree and to rotate the tree left and right. I am not getting this.

Can anybody by looking at the code below tell me how can I possibly r

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 18:06

    in order to rotate it right you need to first check if the parent is not root then if the parent is the right of the grand parent if so, set the right of the grand parent to the child else, set the left of the gran parent to the child

    otherwise, root is child

提交回复
热议问题