Challenge: Tree Depth
Let’s find the depth of a binary tree using recursion.
We'll cover the following
Problem
Given a binary tree, find its depth. The depth of the root is 0. The depth of the tree is the number of edges in the longest branch from the root to the leaf.
Input
A binary tree.
Output
Display the depth of the tree.
Sample input
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.