### Microsoft Interview - I

1. Given an Ellipse class can you derive a Circle class from it?
What all methods would you include in the circle class and what all in
ellipse?
Design a class of curve from which Circle and Ellipse can be inherited.

2. This contained series of questions on C++.
-What are virtual functions? Why are they used? Give examples.
-What are pure virtual functions and abstract classes? When do we use it?
-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?
-What is VTable (virtual table) and what does it do?

3. These were also series of Questions mostly on OS skills:
-What are DLLs? Why do we use them?
-How does DLL work? Can anybody call methods written in DLLs ?
-What are static and shared Library? Which is fast and why?
-Concept of 32-bit OS, virtual memory, inter-process communication etc.

4. Given a BST (Binary search Tree) how will you find median in that?
Constraints:
-No extra memory.
-Function should be reentrant (No static, global variables allowed.)
-Median for even no of nodes will be the average of 2 middle elements and
for odd no of terms will be middle element only.
-Algorithm should be efficient in terms of complexity.

Write a solid secure code for it.

5. 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 e.g.
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.

6. You are given a Linked List and a function declaration as

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

For e.g.
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.

7.Suppose you are passing a string to a Formatter function. Get the
formatted news feed output string such that
-There should be one sentence per line.
-There shouldn't be any spaces i.e. the line shouldn't be blank.
For example:

Input String:
". ....West Indies reached the final of DLF series. .Lalu was invited
to IIM-A once again. . .. .. . Microsoft unveils Zune, an ipod killer. .
. . . "

Output String:

"West Indies reached the final of DLF series.
Lalu was invited to IIM-A once again.
Microsoft unveils Zune, an ipod killer."

Design and write solid secure code for the Formatter Function.

all the best