COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
for(P=L;P!=NULL;P=P
|
|
for(P=L;P!=NULL;P=P
|
|
for(P=L;P!=NULL;P=P
|
|
for(P=L;P!=data;P=P
|
Detailed explanation-1: -What does the following function do for a given Linked List with first node as head? Explanation: fun1() prints the given Linked List in reverse manner.
Detailed explanation-2: -The entry point into a linked list is called the head of the list. It should be noted that head is not a separate node, but the reference to the first node. If the list is empty then the head is a null reference. A linked list is a dynamic data structure.
Detailed explanation-3: -What should be added in place of “/*ADD A STATEMENT HERE*/”, so that the function correctly reverses a linked list. Explanation: *head ref = prev; At the end of while loop, the prev pointer points to the last node of original linked list.
Detailed explanation-4: -Time Complexity: O(n), as list traversal is needed.