Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodedepth problem solution is wrong in this project #4

Closed
balamac opened this issue Jul 7, 2021 · 1 comment
Closed

Nodedepth problem solution is wrong in this project #4

balamac opened this issue Jul 7, 2021 · 1 comment

Comments

@balamac
Copy link

balamac commented Jul 7, 2021

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;
		}
	}
}
@alpha037
Copy link
Owner

alpha037 commented Jul 8, 2021

@balamac Hey, the question (original question on AlgoExpert) asks us to find the sum of all the node depths of the given binary tree.
Thanks!

@alpha037 alpha037 closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants