![]() |
VOOZH | about |
Given a head of Singly Linked List, we have to print all the elements in the list.
Examples:
Input:
👁 linkedlist1 Output: 1->2->3->4->5
Input:👁 linkedlist2 Output: 10->20->30->40->50
Table of Content
Start from the head and follow the next pointer to visit each node, printing the data until the next pointer is NULL.
Steps to solve the problem:
NULL:Program to Print the Singly Linked List using Iteration.
10->20->30->40
At each node, print the data and recursively call the function using the next pointer until the node becomes NULL.
Program to Print the Singly Linked List using Recursion.
10->20->30->40