<to*************@hotmail.comwrote in message

news:11**********************@48g2000cwx.googlegro ups.com...

>

i've known that:

if A ^ B = C, then B = A ^ C, A = B^C.

but anyway how to solve that equation with only np[x] given?

I think this is an easy way to communicate the concept:

Instead of XOR, use addition and subtraction (they are

essentially equivalent when it comes to implementing the

trick of this method, but much easier to comprehend).

First, every node has a field to hold the distance from its

previous-node to its next-node. Note that this is exactly

equal to the sum of the distances from its previous-node

to itself, and from itself to its next-node.

When you iterate, you need pointers to two successive

nodes. Call them A and B. It is easy to compute the

distance between the nodes (B-A), and from there it is

easy to compute the address of A's previous-node [A's

sum-of-distances is reduced by (B-A) and the remainder

applied as an offset to A's address] or of B's next-node

[left as an exercise].

- Risto -