Question: I have an assignment where we must implement a Dynamic Dictionary ADT as a AVL tree, using lazy delete to implement the remove operation. I've

I have an assignment where we must implement a Dynamic Dictionary ADT as a AVL tree, using lazy delete to implement the remove operation. I've gotten that, but unsure how to complete the rotation methods. There are four methods in the given code to do rotations LL, LR, RR, and RL: 

private AVLtree balance(AVLtree t){

if (t == null) return t;

if (height(t.left) - height(t.right) > 1)

if (height(t.left.left) >= height(t.left.right))

t = rotateLL(t); //do an LL rotation

else

t = rotateLR(t); //do an LR rotation

else

if (height(t.right) - height(t.left) > 1)

if (height( t.right.right) >= height(t.right.left))

t = rotateRR(t); //do an RR rotation

else

t = rotateRL(t); //do an RL rotation

t.height = 1 + Math.max(height(t.left), height(t.right));

return t;

}

private AVLtree rotateLL(AVLtree k2){

}

private AVLtree rotateLR(AVLtree k2){

}

private AVLtree rotateRR(AVLtree k2){

}

private AVLtree rotateRL(AVLtree k2){

}

I am lost on how to implement these methods correctly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!