Devise an algorithm to print elements of linked list in reverse without
reversing the linked list. State the time and space complexities.
Solution :
Use recursion
Complexity :- Time : O(N)
- Space : O(N)
void display_reverse(node *list){
if(list){
display_reverse(list->next);
printf("%d\n", list->info);
}
}
No comments:
Post a Comment