Tree recursion
Also written: tree recursion pattern
The pattern for tree questions: return a base answer for an empty tree, ask each child for its answer, then combine them with the node's value. It costs O(n).
Also written: tree recursion pattern
The pattern for tree questions: return a base answer for an empty tree, ask each child for its answer, then combine them with the node's value. It costs O(n).