Home Company Questions Microsoft Interview Questions Microsoft Interview Questions - 9

Login Form




Microsoft Interview Questions - 9 Print E-mail

1. What are virtual functions? Why are they used? Give examples.

 

2. What are static and shared Library? Which is fast and why?

 

3. Concept of 32-bit OS, virtual memory, inter-process communication

 

4. Where are virtual functions stored in the memory? How does the object knows that the virtual function to be called is from base class or derived class?

 

5. What are pure virtual functions and abstract classes? When do we use it?

 

6. An array is of size N with integers between 0 and 1024(repetitions allowed). Another array of integers is of size M with no constraints on the numbers. Find which elements of first array are present in the second array. (If you are using extra memory, think of minimizing that still, using bitwise operators)

 

7. Given an array of strings, print them vertically.

Example :  cat, an, cool  

       c a c
       a n o
       t o
       l

 

8. Suppose you are getting an infinite binary stream of characters then after any point of time you need to print whether the no is divisible by 3 or not, how will you do that?

 

9. You are given a Linked List and a function declaration as node* KReverse(node* head, int k);

KReverse is a function that reverses the nodes of a Linked List k at a time and then returns the modified Linked List.

For Example

Linked List : 1->2->3->4->5->6->7->8->9->10->11

For k = 2

Return Value: 2->1->4->3->6->5->8->7->10->9->11

For k = 3

Return value: 3->2->1->6->5->4->9->8->7->10->11

Write a solid secure definition for the function KReverse.

Constraints:

  • If the no. of nodes in a link list is not a multiple of k then left-out nodes in the end should remain as it is.
  • You have to retain the memory address of the nodes without modifying it i.e. you can't just interchange the values in the nodes.
  • No extra memory allowed.

 

10. Modified 2 color sort problem i.e. you are given an array of integers containing only 0s and 1s.You have to place all the 0s in even position and 1s in odd position. And if suppose, no. of 0s exceed no. of 1s or vice versa then keep them untouched. Do that in ONE PASS and without taking extra memory (modify the array in-place).

For Example :

Input Array: {0,1,1,0,1,0,1,0,1,1,1,0,0,1,0,1,1}

Output Array: {0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1}

Write a solid secure code for it.

 

11. There is a temple, whose premises have a garden and a pond. It has 4 idols, each of Ram, Shiv, Vishnu and Durga. The priest plucks x flowers from the garden and places them in the pond. The number of flowers doubles up, and he picks y flowers out of them and goes to offer it to Lord Ram. By the time he reaches to the pond, he finds the remaining flowers also have doubled up in the meantime, so he again picks up y from the pond and goes to Lord Shiv.This process is repeated till all the Gods have y flowers offered to them, such that in the end no flower is left in the pond. Find x and y.

 

12. An array consists of 2n+1 elements. n elements in it are married, i.e they occur twice in the array, however there is one element
which only appears once in the array. Find that number in a single pass using constant memory. {assume all are positive numbers}

Example :- 3 4 1 3 1 7 2 2 4

Answer :- 7