Comment

Comment by jhallenworld

This reminds of a similar problem: visit all nodes of a tree without using recursion or an explicit stack (or any extra storage). It's useful for marking live nodes during mark & sweep garbage collection with a guarantee that the mark process itself will complete and not cause you to run out of memory.

So this is my amended problem: convert the tree to a same-ordered doubly-linked list without using recursion or an explicit stack.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton