Take out a piece of paper. We’ll be programming on paper.
public interface Iterator211<E> { /** @return true if the iteration has more elements. */ boolean hasNext(); /** @return The next element in the iteration. */ E next(); } public class LinkedList<E> implements List211<E> { /** Holds the items in the list. */ private LinkedNode<E> head; /** The size of the list. */ private int size; private class LinkedListIterator<E> implements Iterator<E> { // your code goes here. } }
Answer the following questions:
What is the Big-O of the hasNext method?
How do we keep track of of the iteration?