Microsoft Interview Question for Software Engineer / Developers






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

would go for an external merge sort

- Anonymous January 21, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what about this approach ?

I am assuming that sorting needs to be done on "id" and its unique for each individual.

1. Lets split the Big file with million entries into n (f1,f2,..fn) small files.
2. Maintain the n small files in n min-heaps.
3. Now in each heap we know the smallest id in that heap, and we have n ids.
4. We take the root of each n heap in memory and find the min amongst them, lets say its xj.
5. Now we know xj is the smallest id present in the whole of file.
6. we swap xj from heap fj with the last element of f1 heap, reduce the size of f1 by one, and heapify f1 and fj from which x1 was originally part of.

Repeat 4, 5, 6 till we run out of heaps.
After that we will have n arrays (f1,f2..fn) which are sorted.
just append these arrays and we have the sorted file wrt to id.

- algooz April 27, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It's similar to what is done in external merge sort

- Anonymous September 07, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

If step 2 can be done then the whole file can be sorted at once. A proper external sort solves the problem. Here is an example:

en.wikipedia.org/wiki/External_sorting

- russoue February 09, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is similar to what is done in external merge sort

- Anonymous September 07, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is similar to what is done in external merge sort

- Anonymous September 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the interviewer wants us to sort in age.
If this is the case, simply open files 1.txt to 100.txt;
read lines and output to the file according to the age;
Finally merge these files into one.
Simpler, LOL.

- Anonymous May 10, 2010 | 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