Question: Reverse a doubly linked list recursively using C++ This is what I have. What am I doing wrong? 37 int reverse_list(node*head) 38 { 39 if(!head)
Reverse a doubly linked list recursively using C++
This is what I have. What am I doing wrong?
37 int reverse_list(node*head)
38 {
39 if(!head)
40 return 0;
41
42 node* temp = head->next;
43 head -> next = head -> previous;
44 head -> previous = temp;
45
46 if(!head->previous)
47 return 0;
48
49 return reverse_list(head-> previous);
50 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
