Microsoft Interview Question for Senior Software Development Engineers


Team: Bing
Country: United States
Interview Type: In-Person




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

My answer:
Well the idea is to 1st process all node whose in-degree is 0. Then keep processing newly added nodes whose in-degree becomes 0. The main part is coming up with a parallel solution.

Algorithm:
- Dedicate a process to go through the graph and add ready nodes (whose in-degree is 0) to a ready-process-queue
- Either use SMP or Master-Slave architecture to assign processing of each node present in the ready queue.
- For efficient tracking of changing in-degrees, maintain a hash<nodeID,indegreeCount>, which is updated for all the outDegree nodes of the currently processed node. Say if we have a link A->B. When processing A we can decrement the indegree count of B.
- Few enhancements are the main process which scans the graph for 0 indegree nodes can be designed to receive a signal when new nodes are ready (whose in-degree has become 0) rather than staying in a busy-wait loop.

- IntwPrep January 17, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 5 vote

Topological sort can do it. I dont know how to make it parallel ?

- Apurv January 18, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Why the down vote?

- DS January 20, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

That's a right way of doing it, a toposort is the way to break down dependencies

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

if i've understood question well, we have some kind network planing. So we need to know which parts of job can be done in parallel. We can do BFS on the graph and mark vertexes. Those vertexes who are on the same level - can be proceed in parallel. But how to find distinct branches, who can be proceed independently - i have no ideas.

- glebstepanov1992 January 17, 2014 | 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