Data Structures | Linked List | Question 17
Consider the following function to traverse a linked list.
Which of the following is FALSE about above function?
The function may crash when the linked list is empty
The function doesn\’t print the last node when the linked list is not empty
The function is implemented incorrectly because it changes head
None of the above
This statement is false because it is common for a function that traverses a linked list to change the head pointer, in order to move through the list. In the given function, the head pointer is initially passed in as a parameter, and then it is updated to point to the next node in the list during each iteration of the while loop. This is a standard approach to traversing a linked list.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Please Login to comment...