Tuesday, February 4, 2020

11. Reverse the elements of linked list using Iterative Version

/*****
Reverseing content of linked list using Iterative version
Reverseiterative() is a function pointer which returns a pointer to a structure
and it takes head as its initial pointer as parameter
*****/



 struct node *Reverseiterative(struct  node *curr); /// Function cal from main()


 struct node *Reverseiterative(struct  node *curr)
{
  
struct node *prev= NULL;
   struct node *nextnode= NULL;
    while(curr)
    {
     nextnode =curr->link;
     curr->link= prev;
     prev=curr;
     curr=nextnode;
    }
    head=prev;
      printf("value of current node is%d",head);
   return 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 ...