Sunday, January 23, 2011

Microsoft Written - 18th January, 2011

Microsoft visited our campus on 18th January, 2011 for campus placement. It was offering Internships to the pre-final year students. The whole 3rd year batch of IT & CSE was excited for this opportunity, and were looking forward to it. Finally the day came, and the PPT was scheduled at 12:00 AM, but it got postponed by a hour. We all were waiting for the PPT, but suddenly we got an announcement that the written exam will be held first, and then the PPT.

Written Exam : The papers were distributed, and we were given one and half hours for 11 questions. I'll try to summarize all the questions, as far as I remember.

No. 1) How will you sort an array of integers?

I was not sure what should I write in this, the code or just the algorithm. So I asked the Microsoft person, he said that code will be preferred but they will not look into the syntax. So wrote the code for Quick Sort ( with a time complexity of O(nlogn) ).
But I guess that they intended us to write the various sorting algorithms we will apply depending upon what type of input we get.

No. 2) Write a code to find the character which has the maximum occurrence in a string of ASCII characters, and print that maximum number.

This seemed pretty easy, I didn't think much into the complexity of the algorithm and wrote a O(n^2) algo. They intented us to write an O(n) algo, which was also easy to think. Just take an array of 256 (as there are 256 ASCII characters), and store the frequency of all the characters from input in this array. And then traverse this array, to find the character with maximum frequency.

No. 3) A code was given and we had to write the output.

This was simple, testing the basic concept of pointers. Only one twist was, which some of them got it wrong,

char c[]="TITAN";
void * vp;
vp = (char *)c;
printf("%s", vp+3);

The output will be "AN". Some of them wrote only "A", not looking that there was "%s", which will terminate with '/0'.

No. 4) A flowchart was given, showing steps of how a email is sent, there were some checking that if the email address is valid, and if the mail contained some matter. We had to write some cases to check if the system was working or not.

I had no idea about this, how to approach this problem. So I didn't attempt this question.

No. 5) Write test cases to test a web search engine?

I had no idea about this question. Test a web search engine, it just seemed out of domain.
Question no. 4 and 5 was for the testing people, and I was poor in testing :(

No. 6) There is a very complex software, which is made available for 90% of the time, and the MTBF ( Mean Time Between Failure) is 200 days. Now the company decides to make the software available for 95%, and hence the mean time for testing increases by 5 days, you need to calculate the new MTBF.

I converted the problem to mathematics, and tried to solve it.

No. 7) What is the disk access time?

It was a multiple choice question, and pretty simple for those who have studied OS.

No. 8)
Find the next number in the series. 5,6,7,8,8,8,8,8, ?

It seemed tough, I tried to think of something and came up with an answer 9. Later came to know this infact was the correct answer. There were possibly two logic to solve this.
*)The most significant digit after decimal in n/(n+1) , where n>=1.
*)The series was part of the second order Josephus Problem, where every second person is marked, and last person remaining is eliminated. This continues till we have a single person.

No. 9)
Given a red coloured cube, the cube is divided such that, after division the one edge of the cube has an edge one-third of the main cube. You need the find the number of cubes with 0 Faces, 1 Faces, 2 Faces, 3 Faces coloured. Why?

They wanted the correct answer and the approach was also important.
*)There will be one cube with 0 faces coloured, the one in the centre.
*)12 cubes with 2 faces coloured, since there are 12 edges in a cube, cube containing those edges will have 2 faces colored.
*)8 cubes with 3 faces coloured, there are 8 corners in a cube.
*)6 cubes with 1 faces colored, as there are 6 faces in a cube.

No. 10) This was a trouble shooting question. Suppose you are watching a video in your desktop, and suddenly the screen goes blank. What are the steps that you will take to find the faulty component?

I thought that there is some fault in hardware, nothing to do with software. Just mentioned some steps that I would take.

No. 11) You had to design a navigating system for a space research organization, that will monitor the take-off and landing of the space ship. Some more requirements were given.

I mentioned some points that came to my mind, mentioned that the system would keep track of the speed. There will be mechanism so that the crew members can interact with each other. Some more points.

Then we attended the PPT, it was a good one. I being a FOSS enthusiast asked then a question, How much is Linux a threat to Windows? , Why does government support FOSS?

After this was the wait for the results, which they said would come the same day. But it came on 19th, at around 12:30 PM. Ankit Arun the TPR of my department, called me up and informed me about the results. And said to come fast.

My interview experience in the next post... :)

Finally "Passed System Test"

With two consecutive disappointments in SRM 492 and SRM 493, finally I code everything well and everything goes fine.
In SRM 492 the 250 problem seemed easy, I developed the logic pretty fast for this problem. Any line would pass through two points, so I fixed two points and calculated maximum number of trees such, that they were co-linear. I coded everything fine, but was missing a very important point. Double precision, I was working with dividing the value, and then comparing them.
If A and B are two double type variables, and they need to be compared for equality, then if we do
if(A == B) , then we may fail, because of floating point precision. Instead we should do if(abs(A-B) <= 1e-9) I failed system test due to this issue, just adding this condition passed system test in practice room.

In SRM 493 the 250 problem, seemed an easy game theory problem, with the concept that, if the first player can win in first chance, then he can win, and if he cant then if the second player can win in first chance then he is the winner. And in other cases there is a draw. I miss interpreted the question, it said reverse their order. There are some black and white stones suppose "OOOXO", where X represent a black stone and O represent a white stone. Reversing the order meant OOOXO --> OXOOO. I interpreted it as OOOXO --> XXXOX. The test cases were such that by writing the code thinking about this logic, it passed all the cases. I got one more wrong answer.

Finally after two failures SRM 494
the 250 seemed easy, I thought of the logic, and implemented the solution, was making some mistakes, fixed those bugs and the submitted. I wanted to get this right, so was coding the solution very patiently. Finally got it accepted, and increased my rating to 1296.

Now I'll practice more and try to get the 500 pointer. That will be my next target. And become top 50 in India.