C++ Program For Printing Reverse Of A Linked List Without Actually Reversing Last Updated : 08 Jul, 2022 Comments Improve Suggest changes Like Article Like Report Given a linked list, print reverse of it using a recursive function. For example, if the given linked list is 1->2->3->4, then output should be 4->3->2->1.Note that the question is only about printing the reverse. To reverse the list itself see this Difficulty Level: Rookie Algorithm: printReverse(head) 1. call print reverse for head->next 2. print head->data Implementation: C++ // C++ program to print reverse of a linked list #include <bits/stdc++.h> using namespace std; // Link list node class Node { public: int data; Node* next; }; // Function to reverse the // linked list void printReverse(Node* head) { // Base case if (head == NULL) return; // Print the list after head node printReverse(head->next); // After everything else is printed, // print head cout << head->data << " "; } // UTILITY FUNCTIONS /* Push a node to linked list. Note that this function changes the head */ void push(Node** head_ref, char new_data) { // Allocate node Node* new_node = new Node(); // Put in the data new_node->data = new_data; // Link the old list off the // new node new_node->next = (*head_ref); // Move the head to point to // the new node (*head_ref) = new_node; } // Driver code int main() { // Let us create linked list // 1->2->3->4 Node* head = NULL; push(&head, 4); push(&head, 3); push(&head, 2); push(&head, 1); printReverse(head); return 0; } // This code is contributed by rathbhupendra Output: 4 3 2 1 Time Complexity: O(n) Space Complexity: O(n) for call stack since using recursion Please refer complete article on Print reverse of a Linked List without actually reversing for more details! Comment More infoAdvertise with us Next Article C++ Program For Printing Reverse Of A Linked List Without Actually Reversing K kartik Follow Improve Article Tags : C++ Linked Lists Microsoft Practice Tags : MicrosoftCPP Similar Reads Javascript Program For Printing Reverse Of A Linked List Without Actually Reversing Given a linked list, print reverse of it using a recursive function. For example, if the given linked list is 1->2->3->4, then output should be 4->3->2->1.Note that the question is only about printing the reverse. To reverse the list itself see this Difficulty Level: Rookie Algorit 2 min read Print reverse of a Linked List without actually reversing Given a singly linked list. The task is to print the linked list in reverse order without actually reversing the linked list.Examples: Input: head : 1 -> 2 -> 3 -> 4 -> NULL Output: 4 -> 3 -> 2 -> 1 -> NULLInput: head: 1 -> 2 -> 3 -> 4 -> 5 -> NULL Output: 5 - 8 min read Reverse nodes of a linked list without affecting the special characters Given a linked list of alphabets and special characters. Reverse the given linked list without affecting the position of the special characters. Examples: Input: g -> @ -> e -> # -> e -> $ -> k -> s -> NULL Output: s -> @ -> k -> # -> e -> $ -> e -> g - 12 min read Javascript Program For Reversing A Linked List In Groups Of Given Size - Set 1 Given a linked list, write a function to reverse every k nodes (where k is an input to the function). Example: Input: 1->2->3->4->5->6->7->8->NULL, K = 3 Output: 3->2->1->6->5->4->8->7->NULL Input: 1->2->3->4->5->6->7->8->NULL, 3 min read Reverse the order of all nodes at even position in given Linked List Given a linked list A[] of N integers, the task is to reverse the order of all integers at an even position. Examples: Input: A[] = 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> NULLOutput: 1 6 3 4 5 2Explanation: Nodes at even position in the given linked list are 2, 4 and 6. So, after reversing 10 min read Like