Linked List traversal


The printList() function takes a linked list as input and prints the elements of the list till NULL pointer is encountered. Here the traversal is in a sequential manner.
The head pointer points to the first node. To traverse the list follow the pointers and display the contents of the node. 

Time complexity: O(n), for scanning the list of size n
Space complexity: O(1), for creating a temporary variable

 
also see

C Programming language
Go Programming language
Linked List Array
Stack Queue
Puzzle Reasoning
Aptitude HTML
Previous articleAptitude
Next articleCreate a Linked List

LEAVE A REPLY

Please enter your comment!
Please enter your name here