Amazon Interview Question for Software Engineer / Developers






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

I guess topological sorting would work here..

- Jit April 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes!

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

Draw a directed graph and do depth first traversal until all elements are visited...A->B means A depends on B

- Sathya April 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

won't dfs traversal use a loop.. we shoudn't be looping..

- krithick.krishnagiri April 11, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

dfs use loop??what that means?

- Sathya April 11, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I mean for dfs u would make use of a for or while loop, the question says that we shouldn't use loops..

- krithick.krishnagiri April 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

dfs wont work
for eg.

- bibhay ranjan April 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

dfs wont work always
for eg.
take task A,B,C and D
let B and C depends on A and D depends on D(construct the graf)
using dfs D can be completed directly through A,B and D...therefor leaving task C behing

topological sort is best to use

- bibhay ranjan April 13, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@krithick.krishnagiri No loops in the question means that there are no cyclic dependencies between the tasks. It does not that a loop cannot be used in the answer

- A April 14, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@bibhay ranjan: i said 'until all elements are visited' meaning u should start dfs again from the next unvisited node and continue this way until all are visited.Infact dfs is a way to do topological sort.google topological sort and see the 2nd link

- Sathya April 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

infact that is topological sorting only

- Anonymous April 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use Singaling mechanism of semaphore?

- sharat April 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A,B,C,D,E

A-->B,D
C-->D
E-->A



a) From the input remove all the tasks which have list of dependencies(A, C, E)
b) Now you have {B, D}, since there is no loop in the tasks we can remove the task that is depended on more than one tasks that is D
c) Now you have {B} then onwards it should be trivial

- Anonymous April 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Its topological shorting.
@Sharat: Which task will execute to give signal to other which are waiting? For that purpose we need topological shorting here.

- Tulley April 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

dfs wont work! give some tyme to the problme and do some paper work

- bibhay ranjan April 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

create the graph and do a kind off topological sort

- camSun April 17, 2011 | 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