Question: The following function reverse ( ) is supposed to reverse a singly linked list. There is one line missing at the end of the function.

The following function reverse() is supposed to reverse a singly linked
list. There is one line missing at the end of the function.
/* head_ref is a double pointer which points to head pointer
of linked list */
static void reverse(Node head_ref){
Node prev = null;
Node current = head_ref;
Node next;
while (current null){
next = current.next;
current.next = prev;
prev = current;
current = next;
}
/`ADD A STATEMENT HERE*/
}
A. head_ref= current;
B. head_ref= prev;
C. head_ref = null;
D. head_ref= next;
 The following function reverse() is supposed to reverse a singly linked

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!