Microsoft Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

What if we reverse all the edges in the dependency graph and then perform topological sort.
Although this will take more time .. but i am just curious to know if this will work or not ?

- Anonymous November 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

That's correct.

- Anonymous November 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

What is the complexity of the topological sort? If there are n nodes, topological sort will basically be BFS of the graph which is of order O(|V|+|E|), now |E| can be of O(n^2) even in DAG. So will it be a O(n) solution? please correct me if I am wrong.

- a.khan November 28, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

but if we do a topological sort with the edge direction reversed, then C will be pointing to both A and B, at that point how will u decide which edge to take ?

- bytecode April 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Do the normal topological sort and print the reverse of the sorted list.

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

Reversed topological sort

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

DFS whenever we color a node black( having visited all its children ), insert it to the tail of a linked list O(1 ) if tail ptr is available.

- subramanian.ganapathy86 January 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

do dfs traversal

- ajay November 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

1)insert in Q all vertex with outdegree 0
2)deque the front element and decrement the outdegree of all adjacent nodes.if outdegree becomes 0,insert it into q.maintain one array ORDER[] which keeps track of dequed element order.

- samrat August 18, 2012 | Flag


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