Write a program to display the linked list in reverse order. Note that the original linked list will not change.
Example with Explanation:
Let's check how the program runs...
Let the input linked list to be: 1->2->3->4->NULL with head at 1
In Main() it calls
reverse_display(1)
----------------------------------------------------------------
reverse_display(1):
node is not null
reverse_display(1->next) thus it calls reverse_display(2)
----------------------------------------------------------------
reverse_display(2):
node is not null
reverse_display(2->next) thus it calls reverse_display(3)
----------------------------------------------------------------
reverse_display(3):
node is not null
reverse_display(3->next) thus it calls reverse_display(4)
----------------------------------------------------------------
reverse_display(4):
node is not null
reverse_display(4->next) thus it calls reverse_display(NULL)
----------------------------------------------------------------
reverse_display(NULL):
node is null
no further call, control returned to reverse_display(4)
----------------------------------------------------------------
At reverse_display(4)
Control returned from reverse_display(4->next)
So it prints the node value that is 4
Control returns to reverse_display(3)
----------------------------------------------------------------
At reverse_display(3)
Control returned from reverse_display(3->next)
So it prints the node value that is 3
Control returns to reverse_display(2)
----------------------------------------------------------------
At reverse_display(2)
Control returned from reverse_display(2->next)
So it prints the node value that is 2
Control returns to reverse_display(1)
----------------------------------------------------------------
At reverse_display(1)
Control returned from reverse_display(1->next)
So it prints the node value that is 1
Control returns to Main function
Thus it displays 4 3 2 1
C implementation to display Linked List in Reverse
Output