Does this algorithm traverse trees (correctly) in logspace?
Background: Assume each vertex is expressed as an integer. A vertex is larger than another if the corresponding integer is larger. A tree is a connected undirected graph with
current has a neighbor larger than
previous, then return the smallest such neighbor.
Otherwise, return the smallest neighbor of
current to the vertex you want to traverse from.
previous to the largest neighbor of
current has at least 1 neighbor.)
2*(N-1) iterations (you'll walk each of the
N-1 edges twice). For each iteration, update
current to the output of