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.

/* Link list node */ struct node { int data; struct node*

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

1 Expert Approved Answer
Step: 1 Unlock

A Explanation headref prev At the end of ... View full answer

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 Data Structures and Other Objects Using Java Questions!