Tuesday, February 4, 2020

12. Reverse the elements of linked list using Recursive Version

/*****
Reversing content of linked list using Recursion
ReverseusingRecursion() is a function  which returns a pointer to a structure
and it takes NULL in prev node and head in curr.
*****/

void ReverseusingRecursion(struct  node *,struct node *); // Global Declaration of function


 ReverseusingRecursion(NULL,head); // Calling ReverseusingRecursion() function from main()


void ReverseusingRecursion(struct node *prev, struct node *curr)
{
    if(curr)
    {
     ReverseusingRecursion(curr,curr->link);
     curr->link=prev;
    }
    else
    head=prev;
}

No comments:

Post a Comment

9_Regular Expressions

Regular expressions- Sometimes in HTML, the developer defines more than one class name ( that’s class input has more than one name Here ...