• + 3 comments

    Recursive implementation in C:

    Node* Reverse(Node *head)
    {
        // The tail of the list has been reached which
        // will now be the new head of the reversed list
        if (head == NULL || head->next == NULL) {
            return head;
        }
    
        Node* nextNode = head->next;
        head->next = NULL;
        Node* newHead = Reverse(nextNode);
        // reverse the nodes
        nextNode->next = head;
        return newHead;
    }