Please write your name and lab section letter at the top of the page.
class ListItem {
public int number;
public ListItem next;
ListItem(int number, ListItem next) {
this.number = number;
this.next = next;
}
public String toString() {
if (next == null)
return (" " + number);
else
return (" " + number + next.toString());
}
}
Using circles to show each ListItem, draw a picture showing the
linked lists created by the code:
ListItem a = new ListItem(100, null),
b = new ListItem(200, a),
c = new ListItem(300, b),
d = new ListItem(400, a);
StackOfInts stack = new StackOfInts(); stack.push(101); stack.push(102); stack.push(103); int a = stack.pop(), b = stack.pop(), c = stack.pop();What values are stored in a, b, and c?
QueueOfInts queue = new QueueOfInts(); queue.enqueue(101), queue.enqueue(102), queue.enqueue(103); int a = queue.dequeue(), b = queue.dequeue(), c = queue.dequeue();What values are stored in a, b, and c?