Vous êtes sur la page 1sur 20

_________

MICROSOFT
PLACEMENT PAPERS
NISHNA 3/14/2011

Microsoft Placement papers 2005 -11

MICROSOFT PLACEMENT PAPERS


2011 Microsoft Placement Paper
1. C++ ( what is virtual function ? what happens if an error occurs in constructor or destructor. Discussion on error handling, templates, unique features of C++. What is different in C++, ( compare with unix). 2. Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list). 3. Given 3 lines of assembly code : find it is doing. IT was to find absolute value. 4. If you are on a boat and you throw out a suitcase, Will the level of water increase. 5. Print an integer using only putchar. Try doing it without using extra storage. 6. Write C code for (a) deleting an element from a linked list (b) traversing a linked list 7. Compute the number of ones in an unsigned integer. ANS. #define count_ones(x) \ (x=(0xaaaaaaaa&x)>>1+(0x55555555&x), \ x=(0xcccccccc&x)>>2+(0x33333333&x), \ x=(0xf0f0f0f0&x)>>4+(0x0f0f0f0f&x), \ x=(0xff00ff00&x)>>8+(0x00ff00ff&x), \ x=x>>16+(0x0000ffff&x)) 8. Compute the discrete log of an unsigned integer. ANS. #define discrete_log(h) \ (h=(h>>1)|(h>>2), \ h|=(h>>2), \ h|=(h>>4), \ h|=(h>>8), \ h|=(h>>16), \ h=(0xaaaaaaaa&h)>>1+(0x55555555&h), \ h=(0xcccccccc&h)>>2+(0x33333333&h), \ h=(0xf0f0f0f0&h)>>4+(0x0f0f0f0f&h), \ h=(0xff00ff00&h)>>8+(0x00ff00ff&h), \ h=(h>>16)+(0x0000ffff&h))

9. Let f(k) = y where k is the y-th number in the increasing sequence of non-negative integers with the same number of ones in its binary representation as y, e.g. f(0) = 1, f(1) = 1, f(2) = 2, f(3) = 1, f(4) = 3, f(5) = 2, f(6) = 3 and so on. Given k >= 0, compute f(k). 10. A character set has 1 and 2 byte characters. One byte characters have 0 as the first bit. You just keep accumulating the characters in a buffer. Suppose at some point the user types a backspace, how can you remove the character efficiently. (Note: You cant store the last character typed because the user can type in arbitrarily many backspaces) 11. Write a function to find the depth of a binary tree. 12. Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted. 13. Assuming that locks are the only reason due to which deadlocks can occur in a system. What would be a foolproof method of avoiding deadlocks in the system.

14. Given an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(nsquare). 15. Given an array of characters. How would you reverse it. ? How would you reverse it without using indexing in the array. 16. An array of integers of size n. Generate a random permutation of the array, given a function rand_n() that returns an integer between 1 and n, both inclusive, with equal probability. What is the expected time of your algorithm? ANS. "Expected time" should ring a bell. To compute a random permutation, use the standard algorithm of scanning array from n downto 1, swapping i-th element with a uniformly random element <= i-th. To compute a uniformly random integer between 1 and k (k < n), call rand_n() repeatedly until it returns a value in the desired range. 17. An array of pointers to (very long) strings. Find pointers to the (lexicographically) smallest and largest strings. ANS. Scan array in pairs. Remember largest-so-far and smallest-so-far. Compare the larger of the two strings in the current pair with largest-so-far to update it. And the smaller of the current pair with the smallest-so-far to update it. For a total of <= 3n/2 strcmp() calls. That's also the lower bound. 18. Write an efficient C code for 'tr' program. 'tr' has two command line arguments. They both are strings of same length. tr reads an input file, replaces each character in the first string with the corresponding character in the second string. eg. 'tr abc xyz' replaces all 'a's by 'x's, 'b's by 'y's and so on. ANS. a) have an array of length 26. put 'x' in array element corr to 'a' put 'y' in array element corr to 'b' put 'z' in array element corr to 'c' put 'd' in array element corr to 'd' put 'e' in array element corr to 'e' and so on. the code while (!eof) { c = getc(); putc(array[c - 'a']); } 19. what is disk interleaving 20. why is disk interleaving adopted

Category SubCategory Location Company

IT Placement Papers Bangalore Microsoft India

About Microsoft India:Microsoft entered India in 1990 and has since worked closely with the Indian government, IT industry, academia and local developer community for ushering in some of the early successes in the realm of IT. Microsoft currently has offices in 13 cities - Ahmedabad, Bangalore, Chandigarh, Chennai, Coimbatore, Hyderabad, Indore, Jaipur, Kochi, Kolkata, Mumbai, New Delhi, and Pune. Increasingly, Microsoft is becoming a key IT partner to the Indian government and the industry. Since its advent, Microsoft has been supporting and fueling the growth of the local IT industry through its partner enablement programs. Since its entry into India, Microsoft has focused on three things, namely: Why Microsoft India- Why should i join Microsoft India?:Microsoft India understand that each employee has unique benefit needs and to meet that we offer flexible benefits. Flexible benefits puts the control in your hands to choose the mix of benefits that best suit you and your family. We make the benefits fit you instead of just offering a standard set of benefits. Heres a

birds-eye view. At Microsoft, youll have an amazing range of opportunities. You might become an expert in a particular field or build proficiencies across many areas. You might be an individual contributor or become a manager. Because we have so many kinds of jobs in so many different places, you can stay in one building, city, or country, or you can cross bordersin person, or virtually.

2009 Microsoft Placement Paper II


1. Besides communication cost, what is the other source of inefficiency in RPC? (answer : context switches, excessive buffer copying). How can you optimize the communication? (ans : communicate through shared memory on same machine, bypassing the kernel _ A Univ. of Wash. thesis) 2. Write a routine that prints out a 2-D array in spiral order! 3. How is the readers-writers problem solved? - using semaphores/ada .. etc. 4. Ways of optimizing symbol table storage in compilers. 5. A walk-through through the symbol table functions, lookup() implementation etc. - The interviewer was on the Microsoft C team. 6. An array of size k contains integers between 1 and n. You are given an additional scratch array of size n. Compress the original array by removing duplicates in it. What if k << n? ANS. Can be done in O(k) time i.e. without initializing the auxiliary array! 7. An array of integers. The sum of the array is known not to overflow an integer. Compute the sum. What if we know that integers are in 2's complement form? ANS. If numbers are in 2's complement, an ordinary looking loop like for(i=total=0;i< n;total+=array[i++]); will do. No need to check for overflows! 8. An array of characters. Reverse the order of words in it. ANS. Write a routine to reverse a character array. Now call it for the given array and for each word in it. 9. An array of integers of size n. Generate a random permutation of the array, given a function rand_n() that returns an integer between 1 and n, both inclusive, with equal probability. What is the expected time of your algorithm? ANS. "Expected time" should ring a bell. To compute a random permutation, use the standard algorithm of scanning array from n downto 1, swapping i-th element with a uniformly random element <= i-th. To compute a uniformly random integer between 1 and k (k < n), call rand_n() repeatedly until it returns a value in the desired range. 10. An array of pointers to (very long) strings. Find pointers to the (lexicographically) smallest and largest strings. ANS. Scan array in pairs. Remember largest-so-far and smallest-so-far. Compare the larger of the two strings in the current pair with largest-so-far to update it. And the smaller of the current pair with the smallest-so-far to update it. For a total of <= 3n/2 strcmp() calls. That's also the lower bound. 11. If you are on a boat and you throw out a suitcase, Will the level of water increase. 12. Print an integer using only putchar. Try doing it without using extra storage. 13. Write C code for (a) deleting an element from a linked list (b) traversing a linked list 14. What are various problems unique to distributed databases 15. Declare a void pointer ANS. void *ptr; 16. Set the highest significant bit of an unsigned integer to zero. ANS. (from Denis Zabavchik) Set the highest significant bit of an unsigned integer to zero

#define zero_most_significant(h) \ (h&=(h>>1)|(h>>2), \ h|=(h>>2), \ h|=(h>>4), \ h|=(h>>8), \ h|=(h>>16)) 17. Let f(k) = y where k is the y-th number in the increasing sequence of non-negative integers with the same number of ones in its binary representation as y, e.g. f(0) = 1, f(1) = 1, f(2) = 2, f(3) = 1, f(4) = 3, f(5) = 2, f(6) = 3 and so on. Given k >= 0, compute f(k). 18. A character set has 1 and 2 byte characters. One byte characters have 0 as the first bit. You just keep accumulating the characters in a buffer. Suppose at some point the user types a backspace, how can you remove the character efficiently. (Note: You cant store the last character typed because the user can type in arbitrarily many backspaces) 19. Reverse the bits of an unsigned integer. ANS. #define reverse(x) \ (x=x>>16|(0x0000ffff&x)<<16, \ x=(0xff00ff00&x)>>8|(0x00ff00ff&x)<<8, \ x=(0xf0f0f0f0&x)>>4|(0x0f0f0f0f&x)<<4, \ x=(0xcccccccc&x)>>2|(0x33333333&x)<<2, \ x=(0xaaaaaaaa&x)>>1|(0x55555555&x)<<1) 20. Compute the number of ones in an unsigned integer. ANS. #define count_ones(x) \ (x=(0xaaaaaaaa&x)>>1+(0x55555555&x), \ x=(0xcccccccc&x)>>2+(0x33333333&x), \ x=(0xf0f0f0f0&x)>>4+(0x0f0f0f0f&x), \ x=(0xff00ff00&x)>>8+(0x00ff00ff&x), \ x=x>>16+(0x0000ffff&x))

2010 Microsoft Placement Paper


1. A version of the "There are three persons X Y Z, one of which always lies".. etc.. 2. There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner.. what is the probability that they don't collide. 3. Write an efficient algorithm and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage. 4. The if (x == 0) y = 0 etc.. 5. Some more bit wise optimization at assembly level 6. C++ ( what is virtual function ? what happens if an error occurs in constructor or destructor. Discussion on error handling, templates, unique features of C++. What is different in C++, ( compare with unix). 7. Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list). 8. Given 3 lines of assembly code : find it is doing. IT was to find absolute value. 9. If you are on a boat and you throw out a suitcase, Will the level of water increase. 10. Print an integer using only putchar. Try doing it without using extra storage. 11. Let f(k) = y where k is the y-th number in the increasing sequence of non-negative integers with the same number of ones in its binary representation as y, e.g. f(0) = 1, f(1) = 1, f(2) = 2, f(3) = 1, f(4) = 3, f(5) = 2, f(6) = 3 and so on. Given k >= 0, compute f(k).

12. A character set has 1 and 2 byte characters. One byte characters have 0 as the first bit. You just keep accumulating the characters in a buffer. Suppose at some point the user types a backspace, how can you remove the character efficiently. (Note: You cant store the last character typed because the user can type in arbitrarily many backspaces) 13. What is the simples way to check if the sum of two unsigned integers has resulted in an overflow. 14. How do you represent an n-ary tree? Write a program to print the nodes of such a tree in breadth first order. 15. Give a very good method to count the number of ones in a "n" (e.g. 32) bit number. ANS. Given below are simple solutions, find a solution that does it in log (n) steps. Iterative function iterativecount (unsigned int n) begin int count=0; while (n) begin count += n & 0x1 ; n >>= 1; end return count; end Sparse Count function sparsecount (unsigned int n) begin int count=0; while (n) begin count++; n &= (n-1); end return count ; end 16. Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ? 17. You're given an array containing both positive and negative integers and required to find the sub-array with the largest sum (O(N) a la KBL). Write a routine in C for the above. 18. Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ]. 19. Write code for reversing a linked list. 20. Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

Microsoft IT campus placement test at Amrita School of Engineering, Coimbatore on 24th January 2011 1.)Written Test -90 mins 2.) 2-3 Rounds of Interview Written round was approx 60 marks. 3 coding questions ..one was a simple recursion based , a 10 marker was about conversion from decimal to binary and third was a simple string manipulation question. Lot of situation based questions. ->How would you test a remote controlled car..write test cases for that. ->How would you handle a situation where your tv goes blank while watching a match. ->what would be your long term and short term solution for flights which run out of fuel in air due to lack of clearance to land durring foggy winter mornings. ->How would you safeguard your system where you hav lot of confidential data in it.

2 code snippets in c/c++ 2 MCQ questions - concepts of DB

OLD MICROSOFT QUESTIONS


Question 1. [10] Find the output of the following program segment #include char *c[]={"ENTNG", "NST","AMAZI","FIRBE"}; char** cp[]={c+3, c+2, c+1, c}; char ***cpp= cp; void main() { printf("%s",**++cpp); printf("%s ",*--*++cpp+3); printf("%s",*cpp[-2]+3); printf("%s",cpp[-1][-1]+1); } Question 2. [5] Write a function delete(struct node** Head) to delete the linked list node by node by deallocating them from the memory and at the end assign the head pointer to NULL. void deleteListTest(struct node* headRef) { struct node* myList=Listonetwothree(); delete(headRef); } //write your code here Question 3. [10] Write a function Compute(int x) such that it prints the values of x, 2x, 4x, 8x ... till the value doesn't exceed 20000. After reaching 20000, it again comes back from ..8x, 4x, 2x, x and stops there. Note: (1) You can't use any local variables in the function (2) You can't use any loops (for or while or do..while) or any GOTO statement. Question 4. [10] List all data structures you would use for a memory management module. Question 5. [5] Share 2 high complexity and 2 low complexity test cases for a coke vending (ATM) machine. Question 6. [10] Explain 3 high priority test cases for the performance of MSN search engine. Answers: Two of the trickiest questions and the easiest ones: (1) AMAZING BEST (3)void Compute (int x) { cout<<<"N"; if(x<20000) { Compute(x*2); } cout<<<"N"; } ////////////////////////////////////////////////////////////////////////////////////////////////////////// Hi Friends I m Kirti. K. Badkundri. For all who r trying for Microsoft or any other company, My one suggestion is that be perfect in basics. If u r perfect in basics u can crack any interview. So Don't loose ur hopes if u have not got recruited still. "NOTHING IS IMPOSSIBLE IN THIS WORLD, BECAUSE IMPOSSIBLE ALSO SAYS THAT I M POSSIBLE" Ok coming to the Microsoft Test conducted on 24th May 2008 in Thakur Polytechnic College in Mumbai. It had

1] Written test 2] Group Discussion 3] Followed by Multiple Technical Rounds. Written test was for 2 hours. I remember only few question 1.Aptitude 2.C 3.C++ 4.Datastructure 5.OS 6.Algorithms 7.RDBMS 8..Net I don't remember questions, as I had written test a month before. How much I remember I m writing here. 1.There was question on Analytical Reasoning, which had 5 questions 2.They gave a square (5*5 square table). And told to find total number of squares. Ans is 55=Sq(5)+Sq(4)+Sq(3)+Sq(2)+Sq(1) 3.Some Questions on Probability. 4.C paper was some what easy. Many Question were on pointers, Strings. 5.In C++ questions were on Inheritance. Some ops 6.In Data Structure they asked to write o/p of very big programs. Which was time consuming. 7.In RDBMS, some questions were on normal forms. And all Basics 8.In Os one question was on LRU Algorithms. Many Basic questions were asked. But it was some what difficult. 9..Net Questions they asked was all basics I think around 450-500 students appeared for test, and only 50 students were short listed for GD round. Package was 8.9 Lacks Only. So Work hard, Be perfect in Basics ////////////////////////////////////////////////////////////////////////////////////////////////////////// Hi Friends These are some of the Microsoft Interview Questions Round 1: 1. What are your interests? (as in academics/topics) 2. Given a string, search it in a set of strings (say among 1000s of string). What data structure would you use to store those 1000 strings and get the results fastest? Answer: I answered hash tables but he said suggest a better one and then gave me one Tree sort of DS and then asked me to compare the two. 3. Reverse a linked list? 4. Find if there is a loop in a linked List? 5. Given two arrays of numbers, find if each of the two arrays have the same set of integers ? Suggest an algo which can run faster than NlogN ? 6. Validate a Binary search tree? (as in the left- right child follow the property) Well I gave some weird eg where the struct was not a Binary tree but if passed through the test will give positive results. then he asked me to solve for that too. Round 2: The interviewer gets a bit serious with each stage. He will test ur work for all possible set of inputs.

Prologue: Well in my case he started with how they require not only a programmer but a designer and coder who writes perfect code. 1. Write a routine that takes input as a string such as "aabbccdef" and o/p "a2b2c2def" or "a4bd2g4" for "aaaabddgggg" write it perfectly as if it should ready to be shipped after you code it. 2. In the same Question (q1) why will u o/p "abc" for the i/p "abc" instead of "a1b1c1" ? 3. Given a NxN matrix with 0s and 1s. now whenever you encounter a 0 make the corresponding row and column elements 0. Flip 1 to 0 and 0 remains as they are. for example 10110 01110 11111 10111 11111 results in 00000 00000 00110 00000 00110 Round 3: 1. Some Questions on the projects listed on your resume? For me some Qs on DB Lock Manager? 2. Given 2 set of arrays of size N (sorted +ve integers) find the median of the resultant array of size 2N. (dont even think of sorting the two arrays in a third array, though u can sort them. Try something better than order N.. order LogN ) 3. Given 1000 bottles of juice, one of them contains poison and tastes bitter. Spot the spoiled bottle in minimum sips? 4. Whats the difference b/w a thread and a process? are Word and PowerPoint different processes or threads of a single process? 5. How does a spell checker routine (common to both, word and PowerPoint) used? I mean is the code copied 2 times for each of the processes in the main memory, if they are different processes or how is it used if they are threads. 1. How could you determine if a linked list contains a cycle in it, and, at what node the cycle starts? There are a number of approaches. The approach I shared is in time N (where N is the number of nodes in your linked list). Assume that the node definition contains a boolean flag, bVisited. struct Node { ... bool bVisited; }; Then, to determine whether a node has a loop, you could first set this flag to false for all of the nodes: // Detect cycle // Note: pHead points to the head of the list (assume already exists) Node *pCurrent = pHead; while (pCurrent) { pCurrent->bVisited = false; pCurrent = pCurrent->pNext; }

A much better approach was submitted by 4Guys visitor George R., a Microsoft interviewer/employee. He recommended using the following technique, which is in time O(N) and space O(1). Use two pointers. // error checking and checking for NULL at end of list omitted p1 = p2 = head; do { p1 = p1-gt;next; p2 = p2-gt;next->next; } while (p1 != p2); p2 is moving through the list twice as fast as p1. If the list is circular, (i.e. a cycle exists) it will eventually get around to that sluggard, p1. 2. How would you reverse a doubly-linked list? This problem isn't too hard. You just need to start at the head of the list, and iterate to the end. At each node, swap the values of pNext and pPrev. Finally, set pHead to the last node in the list. Node * pCurrent = pHead, *pTemp; while (pCurrent) { pTemp = pCurrent-gt;pNext; pCurrent-gt;pNext = pCurrent->pPrev; pCurrent-gt;pPrev = temp; pHead = pCurrent; pCurrent = temp; } 3. Assume you have an array that contains a number of strings (perhaps char * a[100]). Each string is a word from the dictionary. Your task, described in high-level terms, is to devise a way to determine and display all of the anagrams within the array (two words are anagrams if they contain the same characters; for example, tales and slate are anagrams.) Begin by sorting each element in the array in alphabetical order. So, if one element of your array was slate, it would be rearranged to form aelst (use some mechanism to know that the particular instance of aelst maps to slate). At this point, you slate and tales would be identical: aelst. Next, sort the entire array of these modified dictionary words. Now, all of the anagrams are grouped together. Finally, step through the array and display duplicate terms, mapping the sorted letters (aelst) back to the word (slate or tales). 4. Given the following prototype: int compact(int * p, int size); write a function that will take a sorted array, possibly with duplicates, and compact the array, returning the new length of the array. That is, if p points to an array containing: 1, 3, 7, 7, 8, 9, 9, 9, 10, when the function returns, the contents of p should be: 1, 3, 7, 8, 9, 10, with a length of 5 returned. A single loop will accomplish this. int compact(int * p, int size) { int current, insert = 1; for (current=1; current < size; current++) if (p[current] != p[insert-1]) { p[insert] = p[current]; current++; insert++; } else current++; } ////////////////////////////////////////////////////////////////////////////////////////////////////////// Hi Friends Selection procedure and interview questions of Microsoft at Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT)

There were 4 rounds for selection procedure. First round was a written test, second round was group interview and 3rd and 4th rounds were technical interview. Each round had eliminations. Total 143 students were eligible for written test and 16 students were selected for the next round, ie. group interview. Only 8 students were able to go for 3rd round of technical interview. In 3rd round 4 more students were eliminated and remaining 4 students went for final round of technical interview. Only 1 student got an offer finally from Microsoft. Following is the detail about each round. Note: All examples which I will give here are just for your understanding. Interviewer was not giving any examples. Hardly 2 - 3 time interviewer gave examples. Round 1: Written test Paper style: 3 subjective questions Time limit: 1 hour Question 1: Finding output... It was string cruncher program. First remove all repeated consecutive substring with length 1, then delete substring of length 2 and so on... Example: string is "abcabeccced" After removing repeated substring of length 1: "abcababceccced" --> "abcababceced" (2 'c' are removed) After removing repeated substring of length 2: "abcababceced" --> "abcabceced" (substring "ab" is removed) and so on... Question 2: Writing a program. Definition: You are given 3 integer arrays A, B and C of length n1, n2 and n3 respectively. All arrays are sorted. We define triplet of these 3 arrays as (x,y,z) where x is any integer from A, y from B and z from C. We define distance of triplet as maximum difference among triplet elements, i.e. Maximum of x - y, y - z or z - x. Write a program to find minimum triplet distance. (means there are n1*n2*n3 number of possible triplets are possible...among all triplets which triplet has minimum distance...Give only distance, but not triplet elements). Your program must be as much efficient as possible. Question 3: Writing program. Definition: You are given 2 integer numbers in linked list form. Add those 2 numbers. Example: First number is 234 and second number is 35. So, you are provided with 2 linked lists 2->3->4 and 3->5. Your answer must be 2->6->9. (Make sure to take care of carry number). This example was given in paper. Round 2: Group Interview All candidates who had cleared the written test were called for group interview. Here we were given 3 problems one by one. Time limit was between 15 to 20 minutes. Once they gave problem definition we were supposed to think on it and discuss our ideas and logic about solving that problem with one of the representatives from Microsoft. Once that representative was convinced with our logic then we had to write code for that problem on paper. Problem 1: You are given a string. Develop a function to remove duplicate characters from that string. String could be of any length. Your algorithm must be in space. If you wish you can use constant size extra space which is not dependent any how on string size. Your algorithm must be of complexity of O(n). Example: Given string is BANANAS. Output must be BANS. All repeated characters are removed. Problem 2: You have a tree and address of its root. Write an efficient program to test whether a given tree is Binary search Tree or not. (Hint: In-order traversal of binary search tree is sorted in increasing order. Use this property to develop program) Problem 3: You have 2 sorted lists and a function that merge that 2 lists such that output is again sorted and duplicates are removed. That means output is union of those 2 lists in sorted form. Example: First list is 2->3->5->6->8 and second list is 4->5->6->7 and output of function is 2->3->4->5->6->7->8. Develop test cases to test given function such that your test cases ensures that given function works for every situation. That is if inputs are valid then it gives proper output in any case or otherwise it shows error message. Round 3: First Technical Interview All those who had cleared group interview were called for first technical interview. They were taking minimum 2 hours for first interview. Some of us also faced interview for 3 or more hours. Round 4: Second Technical Interview All those who had cleared first technical interview were called for second interview. This was last round of interview. They took 1 to 2 hours for this second interview. I don't remember all the questions which were asked to me in both interviews. But still some of the questions which I can

remember (almost 80 to 90% questions) are listed below. In both interview they ask questions from C/C++, Java, OS, Data structure and algorithms, Microprocessors and compiler constructions. With this, they also asked me to develop more than 6 to 8 programs. You can develop all programs in 5 to 7 minutes. But after writing program they asked to find its complexity and try to reduce the complexity and write the program again. In this way it took almost 15 to 20 min for each program. Some took less than 15 minutes also. Some of the interview questions are as follows: 1. You are given a linked list and block size k. Reverse block of size k from list. For example you are given linked list of 1000 nodes and block size is 5 then instead of reversing whole list, reverse first 5 elements, then 6 to 10 elements, then 11 to 15 elements, and so on...You have singly linked list and your algorithm which you will implement must be in space, that is no extra space is allowed. 2. You are given a tree and any 2 nodes of that tree. Find common parent of both nodes. Develop as much efficient program as you can. 3. In unix there is a command called "tail". Implement that command in C. 4. Some questions about race condition (OS) 5. Questions related to semaphores. 6. Questions related to mutex. Applications of mutex. How to implement mutex in OS? 7. Questions about Critical region (OS). 8. How to ensure that race condition doesn't occur. Give your view as you are OS designer. 9. How to ensure that each process lock the critical region before they enter in it. As OS designer How will you force the process to do this? 10. Questions on IPC 11. Questions on Shared memory and Message passing mechanism. 12. Difference between system call and API call 13. How system call works? What happens when system call is invoked? 14. Different types of system calls? 15. Some questions from microprocessor. About Interrupts 16. Types of Interrupts. What happened when interrupt is called? 17. You are given a hard copy of a program which contains some errors. Your job is to find all types of errors from it. And discuss why is it an error. Write correct program for the same. 18. You are given a linked list and a number n. You also have a function to delete all nodes from that list which are at position which multiple of n in the list. Example: if number is 3 then delete 3rd, 6th, 9th ,... nodes form the list. Develop a program that tests whether given function works properly or not. (In short they are asking me to develop general program for all test cases. By running that program all tests can be performed.) 19. Questions on Java. Exception handling 20. Need of catch and finally block in Java exception handling.. 21. How will you create your own exception.. Explain with example. 22. Some questions on compiler construction. What is parser? What is input to the parser and what is output of parser? Difference between top down and bottom up parser. 23. F(1) = 1. F(2n) = F (n) and F(2n+1) = F(n) + F(n+1). Develop recursive program.

24. You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pattern string. You are not allowed to create new resulting string. You need to allocate some new memory to given existing string but constraint is you can only allocate memory one time. Allocate memory exactly what you need not more not less. 25. Assume that your friend is writing a book. He gives you a file that contains that book. Your job is to develop an algorithm for indexing of that book. In every book there is one index at end which contains some words which are not there in normal vocabulary dictionary. It also contains page number for reference. You can use any data structure you want. You need to justify why you have used that data structure and also need to justify your logic. 26. Question from my B.E. final semester project. Asked me to explain whole project. 27. Question from everything written on my resume. 28. Question from my every project I did. They asked me to explain each project and then how to do some modification? That modification will be suggested by interviewer himself. 29. My experience in Teaching assistantship. 30. They had my written test answer sheet. They opened it and asked me to explain why I gave that output or why I implement that logic. How did I arrive to that solution which I had written in answer sheet. 31. In written test, for second question I had implement a program which was not much efficient. During interview they ask me to optimize my program. They also gave hint to optimize it. 32. During group interview, in second problem I was only able to discuss logic I was unable to develop program in given time limit. Interviewer knew this. She asked me to develop that program during interview. 33. Which is your favorite software tool? If you are allowed to add any feature in it which feature you will add? 34. Which is your favorite subject? Some questions from that subject. 35. Something about yourself, your hobbies, interests, strengths and weakness. I was unable to clear 4th round that is second technical interview. I hope this will help you in your preparation for Microsoft. ////////////////////////////////////////////////////////////////////////////////////////////////////////// Hi Friends There were basically two rounds... One written test and one Technical Interview. In written test they asked 5 questions and time for completing those questions was 90 mins. The lvl of difficulty was on an average 8 out of ten (mean real tough paper)... in which one question was purely program writting (it was quick sort actually but frm question it was hard to strike)... One question was writing output of a program... One question was puzzle type question (in which there was a triangle ABC, and there are '3n' lines horizontal to AB, BC and CD...n line parallel to each side and all cutting other two side...task was to find out formula for two intersection point (Ai,Bj) to (Bp, Cq)...and also no. of possible path)... One question was writing algorithm and last one was suggesting some technique or somthing useful for a swithcing system type railway track (in which rails r travelling and task is to develop efficint track system).... On the basis of the performance few ppl got selected directly for final interview and some other was given second chance to prove in 2nd group test... NO CGPA criteria matters in whole process (thats d best thing...) So guys go get for it... 1...written test ----------it consists of 2 parts 1. Technical (basically includes C, C++, little abt Java) - if u r good in oops u can 2. Aptitude general questions practice r.s agrawal each section will have its own cut-off 2.G.D as usual they will give u a topic

the grp may be around 8 or 6 depending on the croud say best points when ur turn comes (say some thing which is new there at that time) then u can def go thr it

Algorithms : Microsoft Examination Papers 1) What's the difference between a linked list and an array? 2) Implement a linked list. Why did you pick the method you did? 3) Implement an algorithm to sort a linked list. Why did you pick the method you did? Now do it in O(n) time. 4) Describe advantages and disadvantages of the various stock sorting algorithms. 5) Implement an algorithm to reverse a linked list. Now do it without recursion. 6) Implement an algorithm to insert a node into a circular linked list without traversing it. 7) Implement an algorithm to sort an array. Why did you pick the method you did? 8) Implement an algorithm to do wild card string matching. 9) Implement strstr() (or some other string library function). 10) Reverse a string. Optimize for speed. Optimize for space. 11) Reverse the words in a sentence, i.e. "My name is Chris" becomes "Chris is name My." Optimize for speed. Optimize for space. 12) Find a substring. Optimize for speed. Optimize for space. 13) Compare two strings using O(n) time with constant space. 14) Suppose you have an array of 1001 integers. The integers are in random order, but you know each of the integers is between 1 and 1000 (inclusive). In ddition, each number appears only once in the array, except for one number, which occurs twice. Assume that you can access each element of the array only once. Describe an algorithm to find the repeated number. If you used auxiliary storage in your algorithm, can you find an algorithm that does not require it? 15) Count the number of set bits in a number. Now optimize for speed. Now optimize for size. 16) Multiple by 8 without using multiplication or addition. Now do the same with 7. 17) Add numbers in base n (not any of the popular ones like 10, 16, 8 or 2 - I hear that Charles Simonyi, the inventor of Hungarian Notation, favors -2 when asking this question). 18) Write routines to read and write a bounded buffer. 19) Write routines to manage a heap using an existing array. 20) Implement an algorithm to take an array and return one with only unique elements in it. 21) Implement an algorithm that takes two strings as input, and returns the intersection of the two, with each letter represented at most once. Now speed it up. Now test it. 22) Implement an algorithm to print out all files below a given root node. 23) Given that you are receiving samples from an instrument at a constant rate, and you have constant storage space, how would you design a storage algorithm that would allow me to get a representative readout of data, no matter when I looked at it? In other words, representative of the behavior of the system to date. 24) How would you find a cycle in a linked list? 25) Give me an algorithm to shuffle a deck of cards, given that the cards are stored in an array of ints. 26) The following asm block performs a common math function, what is it? cwd xor ax, dx

sub ax, dx 27) Imagine this scenario: I/O completion ports are communictaions ports which take handles to files, sockets, or any other I/O. When a Read or Write is submitted to them, they cache the data (if necessary), and attempt to take the request to completion. Upon error or completion, they call a user-supplied function to let the users application know that that particular request has completed. They work asynchronously, and can process an unlimited number of simultaneous requests. 28) Design the implementation and thread models for I/O completion ports. Remember to take into account multi-processor machines. 29) Write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value. 30) Write a function to print all of the permutations of a string. 31) Implement malloc. 32) Write a function to print the Fibonacci numbers. 33) Write a function to copy two strings, A and B. The last few bytes of string A overlap the first few bytes of string B. 34) How would you write qsort? 35) How would you print out the data in a binary tree, level by level, starting at the top?

Java Questions & Answers What is the difference between an Applet and an Application? What are java beans? What is RMI? What gives java it's "write once and run anywhere" nature? What are native methods? How do you use them? (How does Java inheritance wor?k

How many different types of JDBC drivers are present? What does the "static" keyword mean in front of a variable? A method? A class? Curly braces {}? Class A subclass B subclass C. All override foo(). I cast C to A and call foo(). What happens? Can C call A->foo()? Access specifiers: "public", "protected", "private", nothing? What does the "final" keyword mean in front of a variable? A method? A class? Does Java have "goto"? Why "bytecode"? Can you reverse-engineer the code from bytecode? How does exception handling work in Java? Does Java have destructors? C++ Questions : Microsoft Examination Papers What is Operator, Operand, Expression, Statement in 'C'? What is polymorphism?

What is operator overloading? What are templates? Declare a void pointer. Declare a function pointer which takes a pointer to char as an argument and returns a void pointer. Type-define a function pointer which takes a int and float as parameter and returns a float *. What does the following C statement do? while(*c++ = *d++); assuming c and d are pointers to characters. How do you call a C module within a C++ module. What is the difference between run time binding and compile time binding? Discuss. C h e ta n a S Compare and contrast C++ and Java. Why does C/C++ give better run-time performance then Java? Does C++ come with in-built threading support. Class A derives B derives C. All have foo(). I cast C to A and call foo(). What happens? All classes A, B, C have default constructor, foo() that calls parent foo() and allocates 100 bytes to their own private local variable, and a destructor that frees the 100 bytes. I create a C object and then destroy it. What's the problem? Did all the memory get freed? What if I create C, cast to A, and then destroy it. How would I make sure memory is freed? (destructor must be virtual" and each destructor must call parent destructor) What errors are caught at compile time vs link time? What is the value of "a" after this? int (*a) [10]; a++; What is wrong with this? main(){ int *ptr; *ptr=10; } Given int n, i=10, j=20, x=3, y = 100; What is the value of n and y at the end of each of the following expressions? a) n = (i > j) && (x < ++y); b) n = (j - i) && (x < y++); c) n = (i < j) || (y+=i); int x = 5; int y = 7; What is the value of x and y after the expression y+=x++; What's the difference between C and C++? (What does Public and Private mean in C++ Is it possible to keep 2 stacks in a single array, if one grows from position one of the array, and the other grows from the last position. Write a procedure PUSH(x, s) that pushes element x onto stack S, where S is one or the other of these two stacks. Include all necessary error checks. ////////////////////////////////////////////////////////////////////////////////////////////////////////// Analytical : Microsoft Examination Papers 1) If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts? 2) If you could remove any of the 50 states, which state would it be and why? 3) If you are on a boat and you throw out a suitcase, will the level of water increase?

4) There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner. What is the probability that they don't collide? 5) Three men were renting a motel figuring the room cost 30 dollars they would pitch in ten a piece. The room was only 25 so they each gave the bell boy ten,(tip)the bellboy didn't think that would be fair so he gave them each back 1 dollar and kept 2 for himself. What happened to the other dollar? ////////////////////////////////////////////////////////////////////////////////////////////////////////// Thinkers : Microsoft Examination Papers 1) How are M&Ms made? 2) If you had a clock with lots of moving mechanical parts, you took it apart piece by piece without keeping track of the method of how it was disassembled, then you put it back together and discovered that 3 important parts were not included; how would you go about reassembling the clock? 3) If you had to learn a new computer language, how would you go about doing it? 4) You have been assigned to design Bill Gates bathroom. Naturally, cost is not a consideration. You may not speak to Bill. What was the hardest question asked of you so far today? 5) If MS told you we were willing to invest $5 million in a start up of your choice, what business would you start? Why? 6) If you could gather all of the computer manufacturers in the world together into one room and then tell them one thing that they would be compelled to do, what would it be? 7) Explain a scenario for testing a saltshaker.

8) If you are going to receive an award in 5 years, what is it for and who is the audience? 9) How would you explain how to use Microsoft Excel to your grandma? 10) Why is it that when you turn on the hot water in any hotel, for example, the hot water comes pouring out almost instantaneously? 11) Why do you want to work at Microsoft? 12) Suppose you go home, enter your house/apartment, hit the light switch, and nothing happens - no light floods the room. What exactly, in order, are the steps you would take in determining what the problem was? 13) Interviewer hands you a black pen and says nothing but "This pen is red." ////////////////////////////////////////////////////////////////////////////////////////////////////////// Applications : Microsoft Examination Papers 1) How can computer technology be integrated in an elevator system for a hundred story office building? How do you optimize for availability? How would variation of traffic over a typical workweek or floor or time of day affect this? 2) How would you implement copy protection on a control, which can be embedded in a document and duplicated readily via the Internet? 3) Define a user interface for indenting selected text in a Word document.

4) Consider selections ranging from a single sentence up through selections of several pages. Consider selections not currently visible or only partially visible. What are the states of the new UI controls? How will the user know what the controls are for and when to use them? 5) How would you redesign an ATM? 6) Suppose we wanted to run a microwave oven from the computer. What kind of software would you write to do this? 7) What is the difference between an Ethernet Address and an IP address? 8) How would you design a coffee-machine for an automobile?

9) If you could add any feature to Microsoft Word, what would it be? 10) How would you go about building a keyboard for 1-handed users? 11) How would you build an alarm clock for deaf people? ////////////////////////////////////////////////////////////////////////////////////////////////////////// Algorithms & Coding : Microsoft Examination Papers 1) You have b boxes and n dollars. If I want any amount of money from 0 to n dollars, you must be able to hand me 0 to b boxes so that I get exactly what I request. "The two questions were" What are the restrictions on b and n, and how is money distributed among the boxes? 2) What is the sum of the numbers from 1 to 1000? 3) You are an employer. You have ten employees. Each month, each one of your ten employees gives you ten bags of gold. Each bag of gold has ten pieces of gold in it. Each piece of gold weighs one pound. One of your employees is cheating you by only putting nine pieces of gold in each of his ten bags of gold. You have a scale (not a balance, a scale), and you can only take one measurement from the scale, only one (1) reading. How can you tell which of the ten employees is cheating you by using this scale and only taking one measurement? 4) How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started. 5) How would go about finding out where to look for a book in a library? (You do not know how the books are organized beforehand) 6) Imagine you are standing in front of a mirror, facing it. Raise your left hand. Raise your right hand. Look at your reflection. When you raise your left hand your reflection raises what appears to be his right hand. But when you tilt your head up, your reflection does too, and does not appear to tilt his/her head down. Why is it that the mirror appears to reverse left and right, but not up and down? 7) You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same? 8) You are given a scale which you are to use to measure eight balls. Seven of these balls have the same weight: the eighth ball is heavier than the rest. What is the minimum number of weighs you could perform to find the heaviest of the eight balls? Remember it's a scale not a balance. (i.e. It can just tell you if one side is heavier than the other it can't give you the exact weight). 9) How would you design a toaster? 10) How would you design an universal remote control? 11) How would you design a clock for a blind person? 12) How many miles of road are there in the US 13) There are n couples attending a party. Each one shakes hands with the persons he doesn't know. (Assuming each person knows his/her partner) Mary and John are a couple. John asked the rest of the party-attainders how many times he has shaken hands. Each one gives a unique answer. How many times does Mary shake hands? ////////////////////////////////////////////////////////////////////////////////////////////////////////// Databases : Microsoft Examination Papers 1) What are two methods of retrieving SQL? 2) What cursor type do you use to retrieve multiple record sets? 3) What action do you have to perform before retrieving data from the next result set of a stored procedure? 4) What is the basic form of a SQL statement to read data out of a table? 5) What structure can you have the database make to speed up table reads? 6) What is a "join"? 7) What is a "constraint"?

8) What is a "primary key"? 9) What is a "functional dependency"? How does it relate to database table design? 10) What is a "trigger"? 11) What is "index covering" of a query? 12) What is a SQL view?

Vous aimerez peut-être aussi