References
==========

``` {.java}
Person a = new Person("Marc");
Person b = new Person("John");
a.setName("John");
```

`a == b`? And, `a.equals(b)`?

a.  true, true
b.  true, false
c.  *false, true*
d.  false, false

Linked list big-O
=================

Suppose a linked list contains *n* nodes. What are the big-O bounds on
to return the first element in the list, and to return the last element
in the list? (There is no tail reference for this list.)

a.  O(1) for each
b.  *O(1) for the first, O(n) for the last*
c.  O(n) for the first, O(n\^2) for the last
d.  O(n) for each

Linked list insert 1
====================

(`Node` is shorthand for `LLStringNode`)

``` {.java}
Node head = new Node("x");
head.setLink(new Node("y"));
```

Starting from `head`, what are the contents of this list?

a.  "x"
b.  "y"
c.  *"x", "y"*
d.  "y", "x"

Linked list insert 2
====================

``` {.java}
Node head = new Node("x");
head.setLink(new Node("y"));
Node tmp = head;
head = new Node("z");
head.setLink(tmp);
```

a.  "x", "y", "z"
b.  "y", "z", "x"
c.  "z"
d.  *"z", "x", "y"*
e.  "y", "x", "z"

Linked list manipulation
========================

Suppose `x` is a node in the middle a large linked list. What will be
the effect of `x.setLink(x.getLink().getLink())`?

a.  nothing, this command won't compile
b.  delete `x` from the list
c.  *delete the node following `x` from the list*
d.  make `x` the last node of the list
e.  a `NullPointerException` will be thrown

Fiddling with `size()`
======================

``` {.java}
public int size() {
  int count = 0;
  LLStringNode node = log;
  while (node != null) {
    count++;
    node = node.getLink();
  }
  return count;
}
```

What happens if we reverse the lines inside the `while` loop?

a.  a `NullPointerException` could be thrown
b.  `count` would be too small by 1
c.  the method would not compile
d.  *nothing would change*

