LinkedQueue Practice Quiz
Practice Problem
Take out a piece of paper and put your name on the upper right corner.
Write the following method for the LinkedQueue class:
public interface Queue211<E> {
boolean add(E e); // add e to the end of the queue. May throw an IllegalStateException
E element(); // returns the front of the queue w/o removing
boolean offer(E e); // inserts e to into the queue.
E peek(); // returns the front of the queue or null.
E poll(); // removes and returns the front of the queue or null.
E remove(); // removes and returns the front of the queue, may throw an IllegalStateException.
}
public class LinkedQueue<E> implements Queue211<E> {
private LinkedNode<E> front;
private LinkedNode<E> rear;
private int size;
...
public E poll() {
// your code here.
}
...
}
Be sure to write JavaDoc comments for your code.
Conduct a quick review of your code, before you are done.
After the code, write an explanation the Big-O performance of the poll method.
Time Remaining:
You can restart the timer by reloading the page.
Try to complete the problem in 15 minutes.
If you cannot complete the program in 15 minutes, you can watch me solve the problem in a text editor.