515 views

1 Answer

Best answer
2 votes
2 votes

A) If say a linked list contains no elements then both p and q pointer will point to NULL.

B) If one element only then p will be non NULL whereas q will be NULL.

C) Else normal traversal will be done till q is non NULL 

So considering all cases the loop should be allowed to run if either p != NULL or q != NULL.

So C) option should be the  correct answer.

selected by

Related questions

0 votes
0 votes
1 answer
1
Mrityudoot asked Feb 25
175 views
How can we find the highest element in a singly linked list in O(1)? We are free to use any extra space.
9 votes
9 votes
2 answers
4
GO Classes asked May 4, 2022
505 views
If $f(n) = O(g(n))$ and $f(n) = \Omega(g(n)),$ then it is always true that$f(n) = o(g(n)).$$f(n) = \theta(g(n)).$$f(n) = \omega(g(n)).$both A and B are always true.