Tree Traversal

DFS will only store as much memory on the stack as is required for the longest root to leaf path in the tree. In other words, it space usage is O(h)\text{O}(h) where hh is the height of the tree.

Last updated