Okay, let's work it through
Step 1: remembered = /, cur = a
Step 2: remembered = a, cur = b
Step 3: remembered = b, cur = c
Step 4: remembered = b, cur = d
Step 5: remembered = d, cur = c
Step 6: remembered = d, cur = d <-- Loop detected
No algorithm except remembering every place you've ever been
will detect a cycle instantly. All of the "clever" algorithms
that use constant space sacrifice instant detection and
settle for "soon enough" detection.
-- -Colin- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu