What are the two required properties of a recursive function


What are the two required properties of a recursive function? Explain each in a few words. Write a recursive C function (pseudocode acceptable) to traverse a linked list of nodes from front to back. Don\'t forget to free() the nodes.

Solution

2.
Recursive case:
This defines how the recursive call is done.
Base case:
This defines the condition for which the recursive calls stop.


3.
// structure assumed:
struct Node{
   int data;
   Node *next;  
};

// Which nodes do you want to free. Do you want to clear the list as we traverse? Give the details and I\'ll modify the function accordingly.

void traverse(Node *root){
   if(root == NULL) return;
   traverse(root->next);
}

 What are the two required properties of a recursive function? Explain each in a few words. Write a recursive C function (pseudocode acceptable) to traverse a l

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site