Microsoft Interview Questions

4 04 2009

These Are one 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.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 a the 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
    1 0 1 1 0
    0 1 1 1 0
    1 1 1 1 1
    1 0 1 1 1
    1 1 1 1 1

    results in

    0 0 0 0 0
    0 0 0 0 0
    0 0 1 1 0
    0 0 0 0 0
    0 0 1 1 0

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 resultent 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.

Microsoft Interview Questions and Answers

 

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++;
}





Microsoft paper – Aptitude

4 04 2009

Computer Architecture

1. Explain what is DMA?
2. What is pipelining?
3. What are superscalar machines and vliw machines?
4. What is cache?
5. What is cache coherency and how is it eliminated?
6. What is write back and write through caches?
7. What are different pipelining hazards and how are they eliminated.
8. What are different stages of a pipe?
9. Explain more about branch prediction in controlling the control hazards
10. Give examples of data hazards with pseudo codes.
11. How do you calculate the number of sets given its way and size in a cache?
12. How is a block found in a cache?
13. Scoreboard analysis.
14. What is miss penalty and give your own ideas to eliminate it.
15. How do you improve the cache performance.
16. Different addressing modes.
17. Computer arithmetic with two’s complements.
18. About hardware and software interrupts.
19. What is bus contention and how do you eliminate it.
20. What is aliasing?
21) What is the difference between a latch and a flip flop?
22) What is the race around condition? How can it be overcome?
23) What is the purpose of cache? How is it used?
24) What are the types of memory management?





MICROSOFT PAPER ON 24TH MAY AT MUMBAI

4 04 2009

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 loss u r 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 which  I attended.I attended on 24th May 2008. It was 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 like this. 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
All the Best to one & every one.





MICROSOFT PAPER ON 5TH SEPTEMBER,2008

4 04 2009

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<if(x<20000) {
Compute(x*2);
}
cout<}





Microsoft Paper @ Ohio College

4 04 2009

1) Coldest planet:Pluto
2) INS Shivali is the first:
3) Which one of the following was NOT indegineously developed?:Prithvi/Akash/Agni
4) Full form of SARS
5) Anthrax is a :Virus/Bacteria/…/…
6) Dakshina Gangothri is:Ganga’s origin/Indian camp @ antartica/…/…
7) Which of the following is a chemical weapon:Mustard Gas/Marsh Gas/…/…
8) A question based on Coding and Decoding
9) Another question similar to above
10) Question on series completion
11) Another series completion question
12) Where is Institute of Forensic Science?:Hyderabad
13)A G.K question based on chromosomes in males and females
Sample technical questions asked in test last year in CSE :
1) Banker’s algorithm is used for: Deadlock Avoidance
2) A LOT of questions were based on generating strings from a given grammar. 
3) A circle(dot) shown in the PCB is:Vcc/Grnd/Pin 1/Pin 14
4) Program Segment Prefix in MS-DOS 5.0 is:
5) Some IP addresses were given and the question was to select the private addess from it(?)
6) 10Base2 and 10Base5 wires refers to:
7) A question on sliding-window protocol
8) Which of the following require a driver?:disk/cache/ram/cpu
9) A LOT of mathematical questions which were asked from calculus,trigonometry…

The questions asked in ECE were mainly from Control Systems, Communications EMT and microprocessor
Make sure that u know the fundas of microprocessors useful in interview also: see if u know these questions
1. Which type of architecture 8085 has? 
2. How many memory locations can be addressed by a microprocessor with 14 address lines? 
3. 8085 is how many bit microprocessor? 
4. Why is data bus bi-directional? 
5. What is the function of accumulator? 
6. What is flag, bus? 
7. What are tri-state devices and why they are essential in a bus oriented system? 
8. Why are program counter and stack pointer 16-bit registers? 
9. What does it mean by embedded system? 
10. What are the different addressing modes in 8085? 
11.What is the difference between MOV and MVI? 
12. What are the functions of RIM, SIM, IN? 
13. What is the immediate addressing mode? 
14. What are the different flags in 8085? 
15. What happens during DMA transfer? 
16. What do you mean by wait state? What is its need? 
17. What is PSW? 
18. What is ALE? Explain the functions of ALE in 8085. 
19. What is a program counter? What is its use? 
20. What is an interrupt? 
21.Which line will be activated when an output device require attention fromCPU?                                                                                          

Then comes the interview questions asked in ECE interview were fundamental.Qustions asked in my interview were:
Director
1. Which college and university are you coming from?
2. Did you appear for GATE? Why are you not interested in higher studies?
3. Did you appear for IES?
4. Did you appear for any other board interview of public sector?
5. The subjects you have learned in college can be divided into three- basic electronics, communi-cation and digital logic. Tell me any five subjects you like.
(I told radar and navigational aids, electronic warfare, satellite communication, biomedical instrumentation, fuzzy electronics and basic digital electronics as my subjects)
Board member1 (QUESTION LEVEL- MODERATE)                
1. Write the truth table for full adder and implement it in NAND gate only.
2. What’s the difference between looping 0s and 1s in K map?
3. Difference between microprocessor and micro controller
4. Microprocessors you are familiar with
5. How will you send and receive data to a micro-processor? (One method is I/O mapped I/O which is the other one?)
6. Radar range equation?
7. Does the radar range depend upon the frequency of the signal transmitted?
8. What is Doppler shift? What is its importance?
BOARD MEMBER -2 QUESTION LEVEL- TOUGH) 
1. I will make two fuzzy statements. Pencil is long. Table is long. What is the term long signify?
2. What is a membership function?
3. What are the design criteria for very low frequency amplifier?
4. Can you measure distance with the help of CW radar? If so how?
5. How will you design a stable oscillator? (Not with crystal oscillator because temperature affects it)
6. You have designed an amplifier. After few days it is found that its gain have changed. What might be the reason?                  
BOARD MEMBER-3 (QUESTION LEVEL- MODERATE) 
1. A plane is moving in a circular path around the transmitter of the radar. Will there be Doppler shift detected in the radar?
2. State Keplers laws
3. Why there is more geo synchronous satellite?
4. The angular difference between two satellites is 2 degree. What is the maximum number of satellites needed to cover the whole earth?
5. What is the minimum number of satellites needed to cover the whole earth?
BOARD MEMBER-4 QUESTION LEVEL- MODERATE) 
1. Which is the law of conservation involved in the second of Keplers?
2. Why do you explain elliptical orbit while stating Kepler’s law? Why not circular orbit?
3. What are the advantages of optical communication?
4. What are the invasive and non-invasive methods of instrumentation?


For CS guys they started with this question: What is a key board? Where u will connec? What will happen if you press the keys?..
For maths guys they asked some questions on series.. I don’t know muchSome guys were selected just by describing the final year project.    
                                                                                                  
1. How can you design a phase detector using a XOR gate? 
2. Questions abt differentiator and integrator. What will happen if we increase/decrease the values of R/C? 
3. how will a low/high pass filters behave to different signals –ramp, pulse etc 
4. questions on flip flops 
5. Johnson counter 
6. Questions on microprocessors- what is SIM? 
7. Abt your project. What will happen when this/that happens to your project? 
8. Radar, antenna and satellite communication. 
9. Which is the first/latest communication satellite? 
10. What is apogee /perigee?