 Answer
The program can maintain one more array Z[i] that contains 0 if the corresponding point is not (yet) listed,
and 1 if it is. Since R[i] already defines the return direction, no other information is required for this point. (This option is not implemented in the code example
I put on my web site. It can potentially slow down the program by the graph's connectedness number.) |