Skip to content

Nodedepth problem solution is wrong in this project #4

Closed
@balamac

Description

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;
		}
	}
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions