Question: The following Java method takes a simply linked list as input argument. It modifies the list by moving the last element to the front of
The following Java method takes a simply linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank. Choose the correct alternative to replace the blank line.public class Node int value;Node next;public Node int valuethisvalue value;this.next null;public class MoveToFront public static Node moveToFront Node headNode p g;if head null I head.next nullreturn head;g null;p head;while pnext nullg p;p pnext;ADD A STATEMENT HEREreturn head;O a q null; pnext head; head p;O b qnext mull; head p; pnext head;O c head p; pnext q; qnext null;O d gunext null; Rnext head; head p;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
