
Stackless Traversal (2018)
ofalkaed
created: July 25, 2025, 7:28 p.m. | updated: July 26, 2025, 6:59 a.m.
Sounds kind of difficult, since we definitely need some sort of stack to remember where we are during traversal.
In a stack-based traversal only one temporary pointer would be needed to iterate over the array, and in fact we do get away with only writing one word of data in each array during traversal.
However, there is a little more space hiding in the array q which we can use.
Since it scribbles notes on parts of arrays during traversal, the workspace isn’t necessarily in a valid state until it finishes.
In fact, it takes less time to start up an array traversal than the old method, so it’s many times faster on very deeply nested arrays with few elements in each array.
1 day, 3 hours ago: Hacker News: Front Page