• edited by
2,031 views
1 1 vote
p=head;
q=head-> next;
while(A)
{
     .......................................
}


A is the condition to see list is empty or not, which one is valid?

a) p!=NULL;

b) q!=NULL;

c)(p!=NULL)&&(q!=NULL)

d)(p!=NULL)||(q!=NULL)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

a) p!=NULL;

b) q!=NULL;

c)(p!=NULL)&&(q!=NULL)

d)(p!=NULL)||(q!=NULL)

1 Answer

0 0 votes
List is empty means there would not be any node in the list. Means the pointer "head" should point to Null.

'q' will be considered if there exist atleast a single node. So all other three option will be eliminated.(As question is talking about empty list.)

Option A is correct.
Position:
Show:

Related questions

0 0 votes
1 1 answer
619
619 views
deepak_8404 asked Oct 1, 2023
619 views
Consider a lower triangular matrix stored in row major order as p[-25 - - + 749][-25 - - - + 749] with base address = 6800, size of each element = 6 byte. Find the value ...
0 0 votes
1 answers 1 answer
789
789 views
Souvik33 asked Jan 29, 2023
789 views
Consider the following C code snippets, labeled as P1, P2 and P3, the output of P1 is “X”, of P2 is “Y” and of P3 as “Z”. What is the value of “X+Y+Z”P1#include <stdio.h ...
–4 –4 votes
2 answers 2 answers
1.8k
1.8k views
Souvik33 asked Oct 27, 2022
1,768 views
*MSQ*The following figure depicts a a. A tree and only treeb. A tree with 3 nodesc. A graph (Since every tree is a graph)d. A graph and only graph
0 0 votes
1 1 answer
761
761 views
Overflow04 asked Sep 28, 2022
761 views
Can we determine unique tree by Inorder and level order traversal .