Amazon Interview Question for Software Engineer / Developers






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

topologival sort is ancestor sort, means parent should also apprea before the their child in a sorting sequence.

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

First about DFS: It can be InOrder, PreOrder or PostOrder. How to modify it to BFS?
well the question is not quite clear here. Should the BFS be implemented using DFS?
BFS can be implemented using queues.
Second: Topological Sort outputs those vertices with indegrees of 0 first, removing them, find the remaining vertices of indegree 0 until the whole graph is exhausted. (Well indegree means the number of incoming edges on a vertex in a graph). This also can be implemented using queues.

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

I think DFS is equivalent to post-order transverse, not to in-order or pre-order. Using a stack to post-order transverse a binary tree has pretty complicate logic.

- chenming831 June 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it wont be post-order, it takes either inorder or reverse of postorder only

- surender June 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Modification of a DFS implementation to BFS :- simply replace the stack in the implementation with a Queue.

- TheRandomGuy June 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

depth(Tree t)
{
if(t==null)
return 0;
return max(1+depth(t->left),1+depth(t->right))


}

- Santosh Bhima June 21, 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