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. IVExplanation / 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;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.