Linked List Worksheet 1

By Mickey Arnold
Last updated 10 months ago
3 Questions

What is the output?

ListNode x = new ListNode("6", new ListNode ("2", new ListNode("8", null)));

out.println(x.getValue());
out.println(x.getNext().getNext().getValue());
out.println(x.getNext().getValue());


What is the output?

ListNode x = new ListNode("go", new ListNode ("on", new ListNode("at", new ListNode("up", , null ) ) ) );

out.println(x.getValue());
out.println(x.getNext().getNext().getNext().getValue());
out.println(x.getNext().getValue());
out.println(x.getNext().getNext().getValue());


Fill the blanks below to print out the entire list.

ListNode z = new ListNode("go", new ListNode ("on", new ListNode("at", new ListNode("up", new ListNode("over", null ) ) ) ) );

while( *1 ) {
<*2>

<*3>
}

What should fill in <*1>? _______
What should fill in <*2>? _______
What should fill in <*3>?_______