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 value)(this.value = value;this.next = null;))public class MoveToFront (public static Node moveToFront (Node head){Node p, g;if (head == null I| head.next == null)(return head;)g = null;p = head;while (p.next != null)(g = p;p = p.next;/ADD A STATEMENT HERE*/return head;O a. q= null; p.next = head; head = p;O b. q.next = mull; head = p; p.next = head;O c. head = p; p.next = q; q.next = null;O d. gunext = null; R.next = head; head = p;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!