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

Let the variable list represents a pointer to the head of a linked list of nodes

ID: 3716365 • Letter: L

Question

Let the variable list represents a pointer to the head of a linked list of nodes, called LinkedNode; where LinkedNode is defined as follows class LinkedNode int data; LinkedNode next; LinkedNode(int i) data i; next- null; A node called temp must be inserted at the front of the list. (where temp is defined as: LinkedNode(200)) Which of the following sets of codes best describes the situation. Select the one right response LinkedNode temp = new LinkedNode current = list; while(current != null) temp.next-list; list- temp; current - temp; IV temp = list; list = temp; LinkedNode current = list; while(current.next != null) current - temp; Select one a. O c. IV

Explanation / Answer

Answer b. II is correct.

Code II will insert the temp at the front of the list. This code states that:

//Make next of temp as list which is the head of the list

temp.next = list;

//Move the head to point to temp

list = temp;