You could have asked the question in an easier way :)
Now to explain more I assume C language and sizeof int 4 and size of pointer 8.
|
Node 1 |
Node 2 |
Node 3 |
Node 4 |
Node 5 |
---|
|
Address |
Value |
Address |
Value |
Address |
Value |
Address |
Value |
Address |
Value |
data (int) |
1024 |
1 |
2000 |
2 |
0214 |
3 |
5000 |
4 |
0600 |
5 |
link (*) |
1028 |
2000 |
2004 |
0214 |
0218 |
5000 |
5004 |
0600 |
0604 |
0 (null) |
Now, as per the question we have
0600 = p.
And this is works just like a normal assignment but changes the structure of the list as shown in bottom table.
This is actually not correct. we'll have something like
node5->next = p;
because in C language first operand of "=" operator must be an lvalue- 600 is not an lvalue but a constant. An lvalue can be a non-const variable or a pointer but never a constant.
Now, it doesn't end here. I suppose no one will think above this during B.Tech. unless one makes a compiler himself. For this reason Prof. Srikant Sir in IISc. still makes everyone of his course students make a compiler himself for taking compiler course in IISc.
The thing to the last statement is p has an address as well as value. By definition of "=" in C language, the value of p is copied to node5->next and not address. i.e., the value of right operand (rvalue) is copied to the address of left operand (lvalue)- making it a necessity that left operand must have an address. This is all there to l and rvalues.
Now p has the value 0214 (third node address as given in question). So, the final list will be
|
Node 1 |
Node 2 |
Node 3 |
Node 4 |
Node 5 |
---|
|
Address |
Value |
Address |
Value |
Address |
Value |
Address |
Value |
Address |
Value |
data (int) |
1024 |
1 |
2000 |
2 |
0214 |
3 |
5000 |
4 |
0600 |
5 |
link (*) |
1028 |
2000 |
2004 |
0214 |
0218 |
5000 |
5004 |
0600 |
0604 |
0214
|
Making a loop inside the list. Now the list looks like a smoking pipe as shown below (assume the bend is complete).