Consider the C code fragment given below.
typedef struct node { int data; node* next; } node; void join(node* m, node* n) { node* p = n; while(p->next != NULL) { p = p->next; } p->next = m; }
Assuming that m and n point to valid NULL-terminated linked lists, invocation of join will
"Assuming that m and n point to valid NULL-terminated linked lists" – the line says that the linked lists are not infinite they are finite ..
hence option B is correct.
@Rajatagrawal firstly you need to have something to NULL-terminate. The statement points to the fact that the linked list will have atleast one node. (in my opinion, of course).
If $n$ is $NULL$, then it’s not even a linked list, but a just a pointer.
https://www.youtube.com/watch?v=GnqaL8K3v6o
If the list itself would be null, how can that list be called as a valid null-terminated linked list?
I am not able to perceive the question depending on the language! As per me, it should be 'A'.
Please help!
64.3k questions
77.9k answers
244k comments
80.0k users