1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* This is really a linked list class for a linked list of Strings.
 * No loops allowed in these parts!
 */
public class Recursion {
 
  // Class for the links in the linked list.
  // No getters and setters necessary because the fields are public.
  private class Node {
    public String data;
    public Node next;
 
    public Node(String data) {
      this.data = data;
      next = null;
    }
  }
 
  // Pointer to the first Node
  private Node first;
 
  public Recursion() {
    first = null;
  }
 
  // Adds an element to the front of the linked list.  No recursion required.
  public void addToFront(String element) {
  }
 
  // Prints the data of the lists, in order.
  // You'll need a helper method, which I have started for you below.
  public void printInOrder() {
  }
 
  // Helper method
  private void printInOrder(Node node) {
  }
 
  // Prints the list in reverse order, last node first.
  public void printInReverseOrder() {
  }
 
  // Helper method
  private void printInReverseOrder(Node node) {
  }
 
  // Gets the longest word in the list.
  // If more than one word is tied for the longest,
  // you should return the FIRST one.
  public String longest() {
  }
 
  // Helper method
  private String longest(Node node) {
  }
 
  // Gets the contents of the i-th node, counting from 0.
  public String get(int i) {
  }
 
  // Helper method
  private String get(Node node, int i) {
  }
 
  // Remove the i-th node and its data.
  public void remove(int i) {
  }
 
  // Helper method
  public void remove(Node node, int i) {
  }
}