Create a public class called YourBinaryTree that extends BinaryTree, override protected int countEqualToEitherChild(), and return the count
Question:
Create a public class called YourBinaryTree that extends BinaryTree, override protected int countEqualToEitherChild(), and return the count as described above. A portion of the BinaryTree class that you are extending is shown below for reference.
Follow our usual guidelines for writing recursive functions:
1. Identify the base case
2. Make the problem smaller at each step
3. Combine results appropriately
Note that—as usual—you will want sun to act as a wrapper and call a private method private int countEqualToEitherChild (Node current) that starts the recursion on the root node. Note also that the nodes in the tree are Objects and so you should test for equality appropriately.
public class BinaryTree {
protected class Node {
protected Object value;
protected Node right;
protected Node left;
Node(Object setVatue) {
value = setVatue;
}
}
protected Node root;
// Remainder omitted for brevity
}