Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

1) First Find the shortest path between two nodes E1->E2->E3 ....
2) For all the edges : Remove one and calculate the shortest path agin store the path in array with it's weight
path1= {E1,E2, ... En, pathWeight}
pathsArray.add(Path1);
3) then sort the pathsArray depending on pathWeight of the path and get the Kth path you want

- Maher Rezeq September 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

seems good...plz clarify this,..let's say u hv two paths from 1 to 6..
1->3->6
1->2->4->3->6
then which edge is gonna be removed?

- anandaroop.acharia September 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

in this case you will not remove the Start and End node the one in between ,in your case the 3 , lets say we have 1->4->6 , store the path and weight and do again and again for all nodes , then sort the weights and get the k'th one

- Maher Rezeq January 02, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

DIjkstra's algorithm

- Fargushan September 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Travel till least common ancestor.

that will be the path

- vnvaditya February 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Which company?

- Anonymous September 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Think of BFS, count the times you reach the goal node and stop after the k-th time. Adapt BFS to work with weighted edges.

- Emil November 12, 2012 | 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