Question: Consider the following function to traverse a linked list. public void traverse ( Node head ) { while ( head . next ! = null
Consider the following function to traverse a linked list.
public void traverse Node head
while headnext null
System. out.print headelement ;
head head.next;
Which of the following is FALSE about above function?
A The function may crash when the linkedlist is empty.
B The function doesn't print the last node when the linkedlist is not empty.
C The function is implemented incorrectly because it changes head.
D None of them.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
