Recursion and Trees
70 / 170Recursion and TreesLesson 3 of 13About 42 min
Measuring a tree, and walking two trees in step.
The two problems below are these two shapes exactly. One measures how deep the tree goes, the other compares two trees node by node.
Both are short. Get the base cases right and there is nothing else to them, which is why they arrive here rather than later.
You are writing a function that compares two trees for equality of both structure and values. How many base cases does it need before the recursive step?
Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.
Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.