Question: Need to change the function to recursion. Thank you for your help! void remove(struct node **head_ref, int key) { struct node* temp = *head_ref, *prev;

Need to change the function to recursion.

Thank you for your help!

void remove(struct node **head_ref, int key) {

struct node* temp = *head_ref, *prev; prev = NULL;

if (temp != NULL && temp->data == key) { *head_ref = temp->next; free(temp); return; }

while (temp != NULL && temp->data != key) { prev = temp; temp = temp->next; }

if (temp == NULL) return;

prev->next = temp->next;

free(temp); }

int length(struct node*head) { int count = 0; // Initialize count struct node* current = head; // Initialize current while (current != NULL) { count++; current = current->next; } return count; }

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!