Consider the linked list shown in figure below. Assume that the nodes are in the
ID: 3709173 • Letter: C
Question
Consider the linked list shown in figure below. Assume that the nodes are in the usual info- link form. Use this list to answer questions 1.2 AND 3. If necessary, declare additional variables. (Assume that list, p, s, A, and B are pointers of type nodeType.) 1. What is the output of each of the following Ct statements? a. cout S list--info; b. cout A--info; c. cout B-link--info; d. cout link-link>info 2. What is the output of the following CHt code? p = list; while (p != NULL) cout p->info link->info 45 d. list-B e, *A = *B; f. B = A>link->info; g. A--info-B->info; h, list B->link->link; i. B = B->link->link->link;Explanation / Answer
1)
a.list->info , points to 18
b.A->info ==> 32
c. B->link (25)->info ==>25
d. list->link (32)->link(23)->info ==>23
2)
p =list, where p points the header of the linked list
then p->info ,points the data of header
while p->link, point the link of the header
while(p!=NULL), =>traverse the list untill null encountered
so, output:
18 32 23 16 43 87 25 44
3)
a.A=B, valid, pointer A points the pointer B
b.list->link =A->link , valid, link of list will points the link of A
c.valid, list->link->info is replaced with value 45
d.Invalid
e.valid
f.Invalid. B is a pointer, that cannot hold a integer value
g.Valid, B->info is assigned to A->info
h.valid, list holds the link of link of B node
i.valid, B holds the link of link of link of B node
//for any clarification, please do comments