Amazon Interview Question for Software Engineer / Developers


Country: India




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

Every system maintains a min heap (of certain size if memory is a constraint) of distance to printers and also stores reference to printers.
1) When you add a new system to network, its generates the heap and uses root printer.
2) When you remove a printer, the reference becomes null and if a system is using that printer, it will delete the root and does percolate down.
3) When you add a printer, every system inserts the printer to heap.

- Anonymous May 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sounds good but What abt space complexity of the same logic...

- Lucky May 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

A matrix with printer and system as rows and columns. i.e a graph representation.
Each cell can contain the distance between printer and system.

- DashDash May 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If the distances in the network are all equal(say unit distance) apply BFS from the given system to find the nearest printer(s). If the distances are unequal, apply Dijkstra's shortest path algorithm.

- Dumbo May 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

If the distances in the network are all equal(say unit distance) apply BFS from the given system to find the nearest printer(s). If the distances are unequal, apply Dijkstra's shortest path algorithm.

- Murali Mohan May 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use Floyd Warshall algorithm for the whole graph
For dynamic additions, check which node the new printer is connected to and update values accordingly

- Praveen August 12, 2013 | 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