Input linked list is given as 1->2->3->4->5.
Expected Output list is 5->1->4->2->3
Ans:-
1) Reverse the List
2) Display the first node and Reverse the remaining list
3) Repeat same process until NULL.
void fn(struct node * node)
{
struct node * current = node;
reverse(¤t);
if(current->next != NULL)
rec_recursive(current->next);
}
Expected Output list is 5->1->4->2->3
Ans:-
1) Reverse the List
2) Display the first node and Reverse the remaining list
3) Repeat same process until NULL.
void fn(struct node * node)
{
struct node * current = node;
reverse(¤t);
if(current->next != NULL)
rec_recursive(current->next);
}
No comments:
Post a Comment