Adobe Interview Question for Software Engineer / Developers






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

Look at below link for solution...

http://tech-queries.blogspot.com/2008/12/level-order-tree-traversal-in-reverse.html

- Akash December 05, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Think about the question word-level sentence reverse!

Brilliant

- irobert August 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good algo.

- Rad November 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

q.push_back(root)

while (q is not empty) {
node = q.pop_front();
s.push(node)'

if (node->left) {
q.push_back(node->left)
}
if (node->right) {
q.push_back(node->right)
}
}

while (S !empty) {
pop and print.
}

- Tuatha'an September 01, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 0 votes

There is a little problem in there. The tree you print is from right to left, which is not very correct. Tiny change:
q.push_back(root)

while (q is not empty) {
node = q.pop_front();
s.push(node)'

if (node->right) {
q.push_back(node->right)
}

if (node->left) {
q.push_back(node->left)
}

}

while (S !empty) {
pop and print.
}

- billatforest September 06, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

algorithm

(1) while simple traverse make all node's left pointer pointing to its parent, when u get leaves just push it in queue with its level

(2) while considering the levels of the nodes in the queue print the node values

(3) if required revert back to the original tree

- mail2vcp@gmail.com September 30, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Start from root and enqueue to the queue.
2. Dequeue an element and push it to the stack.
3. Enqueue the children from the dequeued node(from step 2).
4. Repeat step 2 and 3 until you reach the leaves.
5. Now print the stack by popping elements until it gets empty.

Hope it's correct! :)

- loonyCoder October 25, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use "reverse-dfs" to solve the problem.
@ Akash, where did you copy those code chunks from?seems to be from some data structure book. anyways that does the same thing as I mentioned above.

- LOLer August 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

and u invented reverse-dfs or whatever that is? height of arrogance

- jaiHo September 30, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

use BFS. it traverse all the node level wise and it requires only one queue.

- Deepak Garg December 11, 2009 | 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