ScapegoatTree extends AbstractSelfBalancingBinarySearchTree { protected int getSubtreeSize(Node node) { if (node == null) { return 0; } if (node.isLeaf()) { return 1; } else { int sum = 1; sum += getSubtreeSize(node.left); sum += getSubtreeSize(node.right); return sum; } } ScapegoatTree();  ScapegoatTree(double alpha); @Override Node insert(int element); @Override Node delete(int element);  }
@Test public void testGetSubtreeSize() { Node root = new Node(4, null, null, null); Node rightChild = new Node(6, root, null, null); root.right = rightChild; Node leftGrandChild = new Node(5, rightChild, null, null); Node rightGrandChild = new Node(7, rightChild, null, null); rightChild.left = leftGrandChild; rightChild.right = rightGrandChild; ScapegoatTree tree = new ScapegoatTree(); Assert.assertEquals(tree.getSubtreeSize(root), 4); }