22: 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.


(1 point) Suppose you have a linked list composed of Nodes:

public class Node<E> {
    public Node<E> next;
    public E data;
}

Write an iterative method boolean contains(Node<Integer> node, int e) that returns true if and only if the list starting at node contains the given integer.

(1 point) Write a recursive definition (not the code) for contains, in the style from lecture.

(1 point) Implement boolean contains(Node<Integer> node, int e) using recursion – no explicit loop constructs (for, while) allowed!