dimanche 18 février 2018

Whats the issue with my code for Linked List reversal Recursive Method?

I am trying to reverse linked list using recursion.When I display the list after reversing I only get the first element of the original list `

        void reve(node *a,node *b,node *c,node *h1)
       {
               if(c->next==NULL)
           {
               c->next=b;
               b->next=a;
                return ;
           }

           reve(a->next,b->next,c->next,h1);
           c->next=b;
           b->next=a;
           if(a==h1)
         {
            a->next=NULL;
         }

         return ;

      }` 

Aucun commentaire:

Enregistrer un commentaire