Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Which of the following instructions would create an initially empty linked li

ID: 3877923 • Letter: 1

Question

1. Which of the following instructions would create an initially empty linked list? a) Node head-new Node(); b) Node head = Node; c) Node head null; d) Node head new Node(0); e) Node head list; 2. Assume that the linked list has at least two Nodes in it. Which of the following instructions will return the secondintvalue in the list? a) return head.getltem; b) return head.getNext.getitem; c) return head.getNext.getNext.getltem; d) return head.getNext.getNext.getNext.getltem; e) It is not possible to return the second int value in the list using head

Explanation / Answer

1 Ans) C.

Here

Node head = null ;

is just declaring a empty node named as head , and it's not yet initialized , so it is still empty.

remaining syntaxes (especially a and d) can not create a empty linked list initially.

2 Ans) B (return head.getNext.getItem).

Here it States that it is returning the item i.e, next to the head one.

i.e, first it will go to head part,i.e, initially at first node and then getNext will move to second node and then it is getting the item in the present node(after these work we will be at second node).