Question: Bit - saving For an AVL tree, decisions need to be made about which rotation to perform based on the balance factor B ( x
Bitsaving
For an AVL tree, decisions need to be made about which rotation to perform based on the balance factor Bx This factor is calculated as the difference in heights of the trees; one way would be to store the height in each tree and keep track of it We want to implement rotateLeft to maintain the balance factor B stored for each tree. These numbers should only take the values when we have a valid AVL tree and thus only take up bits of memory.
Below is an implementation of rotateLeft without keeping track of B and we assume that B is a field in T
Find out how to modify the code below to calculate the new B values. Assume that Tree T is a valid AVL tree, but the new tree may not be a valid AVL tree. Describe in which cases the AVL tree remains valid after a left rotation hint: divide into cases based on the values of TB and Tright.BTree rotateLeftTree T
Tree Tright;
Tright left;
;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
