AVLTree extends AbstractSelfBalancingBinarySearchTree { @Override public Node delete(int element) { Node deleteNode = super.search(element); if (deleteNode != null) { Node successorNode = super.delete(deleteNode); if (successorNode != null) { AVLNode minimum = successorNode.right != null ? (AVLNode)getMinimum(successorNode.right) : (AVLNode)successorNode; recomputeHeight(minimum); rebalance((AVLNode)minimum); } else { recomputeHeight((AVLNode)deleteNode.parent); rebalance((AVLNode)deleteNode.parent); } return successorNode; } return null; }  @Override Node insert(int element); @Override Node delete(int element);  }
@Test public void testDelete() { AVLTree tree = new AVLTree(); tree.insert(20); tree.insert(15); tree.insert(25); tree.insert(23); Assert.assertEquals(tree.size, 4); tree.delete(15); Assert.assertEquals(tree.size, 3); Assert.assertEquals(tree.root.value, (Integer)23); Assert.assertEquals(((AVLNode)tree.root).height, 1); Assert.assertEquals(tree.root.left.value, (Integer)20); Assert.assertEquals(tree.root.right.value, (Integer)25); testTreeBSTProperties(tree.root); }