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

A. *head_ref = prev;
B. *head_ref = current;
C. *head_ref = next;
D. *head_ref = NULL
/* Link list node */ struct node { int data; struct node* next; }; /* head_ref is a double pointer which points to head (or start) pointer of linked list */ static void reverse (struct node** head_ref) { } struct node* prev = NULL; struct node* current = *head_ref; struct node* next; while (current != NULL) { next = current->next; current ->next = prev; prev= current; current next; } /* predict the statement here */ What needs to be added instead of "/* predict the statement here */", so that the function correctly reverses a linked list.
Step by Step Solution
3.46 Rating (153 Votes )
There are 3 Steps involved in it
A Explanation headref prev At the end of ... View full answer
Get step-by-step solutions from verified subject matter experts
