Function to reverse a linked list - recursive solution
void reverse(struct node *pred, struct node *curr)
{
if(curr)
{
reverse(curr, curr -> link);
curr -> link = pred;
}
else
first = pred;
}
void main()
{
reverse(NULL, first);
}
Written by Munia Balayil
No comments:
Post a Comment