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

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!