The Philosophy of the Series: Why Graphs, Trees, and DFS?
Why obsess over a basic recursive Depth-First Search? Because trees and graphs are everywhere—even outside of computing, and especially at every single layer of a computer.
Whether you are looking at embedded systems, digital circuit design, hardware device hierarchies, thread execution paths, file systems, network routing, the topology of the Internet, or UI layout engines (DOM and render trees), you are looking at graphs and trees.
And in today's modern age of Large Language Models (LLMs), Vision Models, and AI, graph traversal is more foundational than ever: neural network backpropagation (reverse-mode automatic differentiation) is literally built on reverse post-order DFS over a computation graph, while reasoning frameworks like Tree-of-Thoughts (ToT), token search trees, and transformer graph traversals are all predicated on DFS and level-order BFS. It is literally all over the place.
In mainstream software engineering, the reflexive rule of thumb is always: "Convert recursion to iteration to prevent stack overflows."
Taking a novel, first-principles approach to attacking this very basic recursive problem allows us to dissect what we think we know and test the limits of what is truly possible. I learned a tremendous amount about hardware registers, compilers, OS kernels, and runtime internals from this one simple problem—and it is genuinely mind-blowing to see how far beyond conventional limits you can go when you question what we think is possible.