The Gateway to Computer Science Excellence
0 votes
50 views

this is a c function  which adds the newly created node  at the end(tail) of link  list . this node is pointed by q and next of this node is already null.

struct *node *add(struct node*head ,struct node *q)

 

the number of ways to fill the boxes so function works correctly….…..??

my dooubt:

while how second is true becz when on;ly one node in list then second will fail…..answer is given as 1 and 2 are true….

in Computer Networks by Loyal (6.2k points) | 50 views
0
Answer given is correct. (1) and (2) are correct.

Even if there is already 1 node in the list, it will work fiine.
0
HOW? WHEN ONLY ONE NODE IS THERE THEN WHILE LOOP WILL NOT EXECUTE THEN HOW SECOND IS CORRECT  ?
0
Yes While will not be executed, if only 1 node is initially present in list, but q->next= null and p->next= q are independent of each other and can be placed in any order.
0
OK GOT IT THANK U

Please log in or register to answer this question.

Related questions

0 votes
0 answers
3
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,644 questions
56,523 answers
195,602 comments
101,283 users