SplayTree extends AbstractSelfBalancingBinarySearchTree { @Override public Node delete(int element) { Node deleteNode = super.search(element); Node successor = null; if (deleteNode != null) { Node parent = deleteNode.parent; successor = super.delete(deleteNode); if (parent != null) { splay(parent); } } return successor; }  @Override Node search(int element); @Override Node insert(int element); @Override Node delete(int element);  }
@Test public void testDelete() { SplayTree splayTree = new SplayTree(); splayTree.insert(22); splayTree.insert(11); splayTree.insert(10); splayTree.insert(16); splayTree.insert(15); splayTree.insert(14); Assert.assertEquals(splayTree.root.value, (Integer)14); Assert.assertEquals(splayTree.root.left.value, (Integer)11); Assert.assertEquals(splayTree.root.left.left.value, (Integer)10); Assert.assertEquals(splayTree.root.right.value, (Integer)15); Assert.assertEquals(splayTree.root.right.right.value, (Integer)16); Assert.assertEquals(splayTree.root.right.right.right.value, (Integer)22); splayTree.delete(16); Assert.assertEquals(splayTree.root.value, (Integer)15); Assert.assertEquals(splayTree.root.right.value, (Integer)22); Assert.assertEquals(splayTree.root.left.value, (Integer)14); Assert.assertEquals(splayTree.root.left.left.value, (Integer)11); Assert.assertEquals(splayTree.root.left.left.left.value, (Integer)10); splayTree.delete(22); Assert.assertEquals(splayTree.root.value, (Integer)15); Assert.assertNull(splayTree.root.right); Assert.assertEquals(splayTree.root.left.value, (Integer)14); Assert.assertEquals(splayTree.root.left.left.value, (Integer)11); Assert.assertEquals(splayTree.root.left.left.left.value, (Integer)10); splayTree.delete(15); Assert.assertEquals(splayTree.root.value, (Integer)14); Assert.assertNull(splayTree.root.right); Assert.assertEquals(splayTree.root.left.value, (Integer)11); Assert.assertEquals(splayTree.root.left.left.value, (Integer)10); testTreeBSTProperties(splayTree.root); }