Detecting undirected cycles in logarithmic space I have a lot of difficulties with constructing algorithms that use $O(\log n)$ space, as I am unsure about how much can be stored on the worktape. 

I am trying to figure out an algorithm for the problem:

UCYCLE = {&lt;G&gt;|G is an undirected graph that contains a simple cycle}


I can't seem to understand how to create an algorithm in logspace that can solve this problem. In my head, it has to store all the previously visited nodes (since it can't visit the same node twice). Also, I am really stuck on how to start searching, when I can't use non-determinism. Can someone help me with some pointers on how to go forward so I can figure out an algorithm? 

(PS: This is not homework, but I need to understand how to create algorithms for problems in L and NL)
For the undirected cycle problem, you can traverse each connected component: at each node, when coming in through edge $k$, leave through edge $k+1$. (We can assume edges are ordered at each vertex.) 

Now vou start such a traversal once from every node $v$, remembering only $v$ and the edge you left $v$ through. If the traversal returns to $v$ through a different edge, then $v$ lies on a cycle. If this is not the case for all $v$, then the graph is acyclic. 

In general, in a logarithmic space algorithm you can only store constantly many pointers into the input and counters.