581 views

1 Answer

Best answer
2 votes
2 votes

Option must be option D.

Explanation :

initially F is pointing to node with value 1.

Step 1 : P = F->link->link->link->link

F->link = 1->link =2

(F->link)->link = 2->link =3

(F->link->link)->link = 3->link = 4

(F->link->link->link)->link = 4->link =5 (Hence P is poinitng at node with value =5)

Step 2 : P->link->link = F->link->link

We are assigning value of (F->link)->link to P->link->link

F->link = 1->link = 2

(F->link)->link = 2->link =3.

Now, P->link = 6

P->link->link = 6->link = null.

Hence last null value will now points to node with value 3.

Step 3 : F->link = p->link

already we have computed p->link .

Hence F->link = 6.(Simple 1st node now point to 6 directly instead of 2).

Printing :

p->data = 5.

F->link->link->link->link->data = 1->6->3->4->5 (data of node 5) = 5

P->link->link->link->link->data = 5->6->3->4->5 (data of node 5) = 5.

selected by

Related questions

1 votes
1 votes
0 answers
1