Adobe Interview Question
84 Interview Reviews |
Back to all Adobe Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Member of Technical Staff at Adobe:
Iterative method to find the height of a tree
| Tags: | trees, recursion, datastructures See more , See less 8 |
Helpful Question?
Yes |
No
Inappropriate?



0 of 0 people found this helpful
by Anonymous:
Returns the max root-to-leaf depth of the tree.
Uses a recursive helper that recurs down to find
the max depth.
*/
public int maxDepth() {
return(maxDepth(root));
}
private int maxDepth(Node node) {
if (node==null) {
return(0);
}
else {
int lDepth = maxDepth(node.left);
int rDepth = maxDepth(node.right);
// use the larger + 1
return(Math.max(lDepth, rDepth) + 1);
}
}