We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In this example the function takes a node, checks if it exists and if it does prints the data in that node. Then it runs that same function (print_list) on the next node (node.next). This will keep calling that function inside of itself until it runs out of nodes.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Print the Elements of a Linked List
You are viewing a single comment's thread. Return to all comments →
It is a recurisve function. You call the function inside of itself.
In this example the function takes a node, checks if it exists and if it does prints the data in that node. Then it runs that same function (print_list) on the next node (node.next). This will keep calling that function inside of itself until it runs out of nodes.