Fresher Microsoft Interview Questions and answers
1. A program was given and we were asked to debug the code so that it works as desired. The program's aim was "finding the meeting point of two linked lists". It was quite simple and some of errors were like in allocating memory, some logical errors. But its doable.
2. Given a Circuit (with resistors), we need to calculate the total resistance. Input will be like AB-5ohm, BC-6ohm, BC-10ohm, BC-20 ohm, CD-5 ohm. BC has been repeated twice implying they are in series. "Write a program by implementing efficient data structure for storing and calculating the total resistance". I used stack using linked list and implemented which works for almost all combinations of circuits (but didnt work for some :D).
3. "Write test cases for reversing words of string ". For eg. "This is nice" is input string and output is "nice is This". We need to write test cases for this program,(not the program for it). Writing some 5 to 10 will do. Start from some of the very simple cases like for eg. "Check whether the program in accepting input".
4. You have been asked to write features of an "Universal Remote Controller". Eg. "It will support TV,System, DTH etc".
The interviews in MS will be a loop process where a person has to attend interviews in a loop(every interviewer will interview us once). We need to satisfy all the four to get into MS.
1. What were your challenging projects? I named one and I was asked to write test cases for that. Interviewer was not satisfied until I gave around 10 test cases.
2.Deletion of a node in linked list.. seems pretty simple , he was expecting a code with good coding standards. From there discussion went upto locks and mutexes in OS.
3.Print a Random word from a file. Input is "path to a file", constraints- No extra memory like hashing etc. All the words in the file should have equal probability.
4.Rectangles overlapping questions, write test cases.(I had seen this already). This is a popular MS question.
Round 2:(only one question)
1.Write c++ working code for Given a large number with many digits, propose a method or data structure to efficiently store them. Addition, subtraction, mult, division should be supported by your design.
Given a matrix, we need to transform it in such a way that if an element is zero, we need to zero out the contents of corresponding row and column(of that element). Only minimal extra space allowed, test cases was also asked. I gave some solutions,but he didnt get satisfied as the I used more space than what he asked.
eg. if the matrix is
1 1 1
1 1 1
1 1 0
the output matrix is
1 1 0
1 1 0
0 0 0.