Adobe Interview Question






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

I believe you mean two binary "search" trees?

- Anonymous March 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If it's two binary search trees, then a possible solution is to do Inorder traversal. If not search tree, any traversal will do. After such a traversal, the data from the binary tree can be stored and then the two arrays can be compared for similarity in data.

- Anonymous March 11, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not necessarily BST,
int sameTrees(Node* a, Node*b)
{
if (a == null && b == null) return (true);
else if (a !=null && b != null)
return ((a->data == b->data)&& (sameTree(a->left,b->left) && (sameTree(a->right, b->right)));
else
return false;

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

plzzzzzz comment on this soln

- sunny March 13, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is a correct solution

- Dot Divx April 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is *not* correct. You cannot assume that the trees are structured exactly the same way. The keys for two trees could be identical but the way they are structured may be different.
Do inorder traversal of the first tree and hash the keys. Now do inorder traversal of the second tree and make sure that all the keys encountered belong in the hash table.

- Anonymous May 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

thats the correct solution. with your approach you are just checking the contents. consider example
1. root : b
left node : a
Right node : c
2 root : a
right node : b
right node of b : c

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

thats the correct solution. with your approach you are just checking the contents. consider example
a a
/ \ AND \
b c b
\
c

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

l

- mail2ankitmalhotra October 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

l

- mail2ankitmalhotra October 26, 2010 | 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