Nodedepth problem solution is wrong in this project
balamac opened this issue · 1 comments
balamac commented
NodeDepths problem in algoexpertsolution
ques: Need to find the depth of the tree.
below is the solution
int nodeDepth(TreeNode t, int ldepth, int rdepth) {
if (t == null) {
return 0;
} else {
ldepth = nodeDepth(t.left, ldepth, rdepth) + 1;
rdepth = nodeDepth(t.right, ldepth, rdepth) + 1;
if (ldepth > rdepth) {
return ldepth;
} else {
return rdepth;
}
}
}