Adobe Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

Do a depth first traversal and keep on increasing parents height as rolling out of the recursion.

- Anonymous August 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

dft is a soln but without dft recursive simple solution exists.

typedef struct node * NODE;

int depth ( NODE nd )
{
return nd?1 + max ( depth ( nd ->left ) , depth ( nd ->right ) ):-1;
}

for height of tree just change -1 in code to 0;

- rocky.iiita August 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

for Java do appropriate syntax changes...

- rocky.iiita August 05, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int maxdeepth(Node *root)
{
if (root == NULL)
return 0
}
else
{
return (1 + max(maxdeepth(root->left),maxdeepth(x->right)));
}

- aalok October 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This will result in the height of the binary tree.

if ( root == NULL ) return -1;

now it will work.

- Ansh2rock January 25, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

sorry my bad...ur code will return the no of levels in the binary tree not height...the value of height and breadth will be the same.

- Ansh2rock January 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think the code is correct but not optimized , for optimization we will have to use dynamic programming.check MIT open courseware dynamic programming.

- ankit May 08, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More