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
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
}
private AVLtree
}
private AVLtree
}
private AVLtree
}
I am lost on how to implement these methods correctly.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
