/*****
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;
}
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