Finish this Reverse LL using Recursion below: #include #include struct node; typedef struct node Node; struct node { int data; Node* next; }; //declare your
Finish this Reverse LL using Recursion below:
#include
struct node; typedef struct node Node;
struct node { int data; Node* next; };
//declare your function here.
int main(int argc, char* argv[]) { Node* head = NULL; int i; Node* temp;
//set up a test list with values 9->8->7->...->0 for (i = 0; i < 10; i++) { temp = (Node*)malloc(sizeof(Node)); if (temp == NULL) { printf("out of memory? "); exit(1); } temp->data = i; temp->next = head; head = temp; }
//call your function to reverse the list (should work for any list given the head node).
//print the reversed list. temp = head; while (temp != NULL) { printf("%d ", temp->data); temp = temp->next; }
return 0; }
/* Define your recursive function here (1) Identify and write the base case or cases (2) Recursive condition. (3) write out the code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started