Reverse a singly linked list
For this, we will use there pointer, namely previousNodePtr, currentNodePtr & nextNodePtr as shown in image.
And update their values in loop.
We call recursive method continuously until we reach at end of list and after we update next pointer. Here is method call stack,
List: [1, 2, 3, 4, ] List after reverse: [4, 3, 2, 1, ] List after reverse (recursive):[1, 2, 3, 4, ]