Tail Call Optimization Archive

Tail Recursive Tree Traversal

Once in a while you may be facing the situation that requires you to walk a tree, do some kind of processing on each node and collect a result (or do other things). In case the tree is arbitrarily large and also arbitrarily branched, you have generally two options (as