23: Even More Recursion
Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.
Suppose you have a tree composed of Node
s:
public class Node<E> {
public E data;
public Node<E> left;
public Node<E> middle;
public Node<E> right;
}
where each node has up to three children.
(1 point) Write a recursive int size(Node<E> node)
method that returns the number of non-null
Node
s in the tree rooted at node
.