I am thinking about the problem of detecting cycles in lisp lists (based on cons cells). Traditional cycle detection algorithms like Floyd's (Tortoise and hare) or Brent's algorithm all assume that there is only a single "next" function. However with cons cells there are two possible next nodes (car or cdr). This means that most cycle detection algorithms can't be applied (at least I think they can't?). The only solution I have found for this is DFS with backlink tracking. Compared to Floyd's algorithm which only uses 2 pointers and a single compare per cycle, using a a full DFS could require the entire dataset to be inserted into a hashtable and requires a hash lookup every iteration. I am looking to see if there are algorithms that does not require O(n) space like DFS, but can still handle detecting cycles in list.
I know this is not a novel problem, because lisp systems have been around forever. This is something they have to deal with whenever they print an object. And it's not only applicable to lisp, but really any graph where nodes can have more then 1 "next". How is this solved in practice?