Log in
Sign up for FREE
arrow_back
Library

Linked List Worksheet 1

star
star
star
star
star
Last updated almost 2 years ago
3 questions
1
Question 1
1.

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());

1
1
Question 2
2.

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());

Question 3
3.
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>?_______