evinda
Gold Member
MHB
- 3,741
- 0
I like Serena said:I have introduced S to keep track of the element that comes after R, which we need to be able to move on to the next element. (Thinking)
It is initialized at the beginning of the for-loop.
The first time it is used is at the end of the for-loop.
And only then is it changed as part of the increment-part of the for-loop. (Wasntme)
Suppose that we have this list:
$$\boxed{3} \to \boxed{1} \to \boxed{5} \to \boxed{2} \to \text{NULL}$$
At the first for-loop, P and R will point to 3, and R will point to 1, right? (Thinking)
Then, the commands:
Code:
Q->next=R->next;
Code:
R->next=P->next
will be executed, right?
P->next points to R, so what will the command
Code:
R->next=P->next