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





ZENSAR PATTERN & INTERVIEW – JUN 2007 AT MEERUT

10 02 2009

Paper : ZENSAR PATTERN & INTERVIEW – JUN 2007 AT MEERUT

I am Dhruv Agarwal and I appeared in a Zensar placement recruitment drive held in our college “Meerut Institute Of And Technology ” from 1-2 June 2007. The selection procedure consists of 2 rounds:

1-Written test
2-Interview(HR+Technical)

The written test comprised of four sections
1-General English
2-Quantitative Aptitude
3-Logical Reasoning
4-Technical (C&C++)
The test was very tough and maximum elimination is done in this round only
total of 200 appox and 76 cleared the written test and shortlisted for the interview. I was one of them

for General English consult (barren)

for Quantitative apti consult r.s.aggarwal and for Technical consult ‘test ur c skills’
i don’t remember exactly the questions but questions were of higher standard. The time duration for written test was 1.20 hours and there was a time slot for each section of about 20 min to each sections

Student selected for a interview were allowed to appear for both (Hr+Technical). Again interview was very tough and out of 76 only 38 were selected finally. I was one of them. I was asked basically about my project and field of interest subjects. I opt for e-commerce. So i was asked questions on E-Commerce technologies like Encryption etc. In the HR round the hr executive was very friendly and asked a general questions like

1-How was ur day
2-Describe about yourself
3-Family background
4-Aim in life
5-What do you think about Zensar

Be frank in ur answer and never think of bluffing the hr because they know everything about u just by reading your face. my interview lasted for 20 minutes. therefore i would like to say u that just believe in yourself and on your luck. if its ur day then nobody can stop u. this is my personal experience. I was selected in my 10th company. So have some patience and just appear in the interview with great confidence and strong will.





ZENSAR PATTERN & INTERVIEW AT MEERUT

10 02 2009

ZENSAR PATTERN & INTERVIEW AT MEERUT

I m vry happy that I finally got placemnt after some rejections. so all of u who r feelin dishearted cheer up coz its all matter of luck, evry one wud get chance.
There are 3 rounds Written, Technical interview & HR round.

1) Written
it consist of 4 sections, each section has around 20 to 25 questns n u wud gt 20 to 22 min to solve.
first section is english :- there were fiil in the blanks, find correct heading for givn passage,reading passage, synonyms,opposites,grammar. this section is little tough bt if ur english is good then u can clear easily.

2) Aptitude
very esy questions on profit&loss,percentages,areas, volumes,time n work,height and distances,series,algebra u shud hav gud speed questions are vry simple. coz my apti is nt vry strong still it was easy fr me.

3) Logic
puzzles from verbal rs aggarwal, coding, series of alphabets, jumbled sentences, to find correct sequences from given sentences, all in all vey easy section jst need gud speed.

4) Technical
I foun it little tough n lengthy bt pepl with gud programmin skills will find it easy there were c, dbms, networkin. mostly questions from c output questions around 10.

At last i wud like to suggest u that wn u gt ur paper start from first section then speed up as they will give seperate time fr each section. so wn u r warnd to turn to nxt section before 5 min thn dnt solve lft out questns instd check the probability of choices that are repeatin n mark those choices in remanin time in each section.
no negative markin so good luck for written exams.





ZENSAR PATTERN & INTERVIEW – 27 APR 2007 – HYDERABAD

10 02 2009

Paper : ZENSAR PATTERN & INTERVIEW – 27 APR 2007 – HYDERABAD

I attended interview for Zensar Technologies at Holy Mary College S R Nagar Hyderabad on 27 April 2007

First there was written test. It had 4 sections: English, Mathematics, Analytical and Technical 20 min were given for each paper.
Except for maths all section were very easy. There were no -ve markings. out of 180 students only 20 were short listed for the 2nd round by gods grace I was one among them

2nd round was technical he asked me around 30-35 question mostly on C++ some from Unix and RDBMS.

Then the hr round was also easy simple question.

Tell me something about ur self

Where do u see urself 5 years from now

Have u done any prj

Why should i hire u and stuff like that

then i was given an essay is “mnc’s coming to india good or bad” ur views

thats it all the best for all of u reading this.





ZENSAR PAPER & INTERVIEW – MAR 2008

10 02 2009

Paper : ZENSAR PAPER & INTERVIEW – MAR 2008

I want to start with a quote that I always try to follow in my life that, “If the victory is certain then even a coward can win but the real brave are those who dare to fight even if they know that their defeat is fixed”. From the day when I joined my college I had the dream to start my career with a growing company where I could get an opportunity to utilize my abilities & skills. This dream seems to be come true when Zensar Technologies visited our campus, It was 3rd of March, 2008, stage was well set, show was just to begin.

Four people came from Zensar for the recruitment and now it’s time for the PPT i.e Pre Placement talk .. in that they have told us about there selection criteria, about Zensar and of course the most important thing the package they are offering us.

They were very strict about their eligibility criteria, and the eligibility criteria was all through 60%, few of our friends are only 1 or 2 marks short of first division in 10th standard but its really mysterious they don’t even allow them to sit just for the one odd mark.

The Selection procedure is normal as other companies, we have to under go 3 stages:
1) Aptitude Test
2) Technical Interview
3) Hr Interview

We all were ready for the Aptitude Test and I was really feeling embrace for few of fine friend who were very intelligent but couldn’t make it just because of the eligibility criteria.

Aptitude Test begins: (there was no negative marking but there is the sectional cut off of 50%)

The test was divided into 4 categories and each of them contains 20 question and 20 min. are provided for each section, and we were forced to solve a section for 20 min. only and once the 20 mins are over then only we can jump to the next section.

First section was the English section, for me it is the toughest hurdle coz I had prepared the articles, prepositions, tenses, synonyms and antonyms but the pattern of the test was totally different, there was a complete sentence in which a fragment is underlined and we have to replace that fragment with the given options, and it was a real hack when I tried out options one by one every one is perfectly fine. I was really confused and the next five question were like

Prem Chandra was a _______ poet, he has written several ______ with his title and still lots of them _______.

In these question I shooted lots of arrows (I hope some of them might hit the target )

Next 5 question were like Heat: temperature:: _______:_______ I m sure that I haven’t answered more then 2 correctly.

And the last five question were based on a passage (I say to me that, “yaar agar English ki sectional cut off cross karna hai to kuch bhikar ke ye sare question thik karne hi padenge”) I read the passage twice and I m sure that I must have answered all the question right.

Two mins were still there, I tried to keep myself calm but I was really frustrated.

Next section was Maths no problem for me at all.. I was quite frustrated coz of mine English section that’s why I was even unable to remember the table of 18 in one of question. I have to find 18 * 9 nothing came in to mind at that time every thing was like ??????? then I done 180-18 to calculate it again was even unable to subtract I said oh god ..what is happening today. Then after a min I regained my senses and I have done 16 questions 100% correct in just 10 or 11 odd mins. Question were very simple like

1)A can do a work in 31 days and B can do the same work in 8 days ,A alone started the work after few days he was joined by B, and the work completed in 10 days . After how many days A is been joined by B.

2)In an election between 2 candidate one have got 53% votes and won by 1057 votes, how many votes were there ?

3)A spent 3589 Rs. In first four months and 5216 Rs. In next eight months, if he saves 2368 Rs per month then what is his salary ?

4)A man sells a bike and a cow in 14000 Rs., by selling his bike he loses 20% and gained 20% in selling his cow, if the total profit was 200 Rs. Then what was the cost price of cow?

5)Two no. are in 2:3 ratio if the three fifth of the first number is added to two third of the second no then the new ratio will be ?

6)The cp a ltrs of milk is 12 rs, a milk man purchases 20lts of milk and wants to earn 200Rs. in the transaction if he sells 20 ltrs of milk then how much water will be the sp of a ltr milk… (too simple its not allegation)

And simple problem on ages, allegation, time and distance etc.

Next Section, Reasoning was avg. not too easy not too tough, an average person can do almost 65% of the question and rest of the question were quite tough,question were like,

A, B, C, D, and E were 3 guys and 2 girls, each one have the b’day in Jan, Feb,..may;

Each one of them like sweets, ice cream…etc.

Note : verbal as well as non verbal reasoning was there (don’t worry it was easy )

Now It’s the time for the Technical Section which was the last section of the paper:

Most of the questions were based on the C output and rest of the question were from networking, Computer Architecture, Operating System. Question were like:

1)which is the fastest : FTP, TELNET, TCP, etc.

2)output:
main(){
int x=20,y=35;
x= x++ + y++;
y = ++x + ++y;
printf(“%d %d”,x,y);
}

3)char *p[]=”rachit and devender”;
printf(“%C”,++(p[4]));

4)const char *p[]=”abhishek and Ankur”;
char k=’a';
p[1]=k;
printf(“%s”,p);

5)main(){
extern int i;
i=5;
printf(“%d”,i);
}

6) main(){
int i,j=2;
if(i%j !=0)
j=5;
printf(“%d”,j);
}
For what values if i the output will be 5 : options 1)when i is even 2) odd 3)prime 4) fro all

7)complexity of merge sort .?

8)which sorting also will use to sort {1,2,3,4,5} ?

9)which cpu register holds the address of next instruction?

10)Main(){
Char *p[]=”pradeep mani”;
Printf(“%c%c%c%c”,p[i],i[p],(*p+1),*(p+1));
}

11) select * from dual ; output..??

12) we cant typedef (i) pointers (ii) function (iii) double (iv) I and II both

above are some of the question which are been asked in the 4th section of the Aptitude test.

Now they asked us to wait for 30 mins, it was really a tough time our heart was beating at full speed.. 30 mins seems to be 30 years,

Now the result is been declared..

A person came and said that only 5 people are selected every one of us were astonished, we were assuming that at least 15 people will crack this Aptitude but that was really strange, My name was there, but I really feel bad for all my friends who were unable to cross this barrier. They have given us a form to fill up, it’s a general details entry form, they take our CVs and ask us for reporting them with in 15 Mins.

It was really tough hurdle coz Zensar mainly focuses on the technical round but I was well prepared for this round coz I may not be totally perfect, but parts of me are excellent.

Now the battle of questions and answer started.

We were in our college at 9:00 am and now it was around 2:30 pm I was the second person to go for the technical round,

They asked me have you taken your lunch I said, “no, I don’t even had my break fast”, then they ask me are you hungry I have some snacks with me I said, “no thanks, I m just hungry for the job”. Then they started bombarding questions,

1)what is pointer to a function ..
2)Explain the working of pointer to a function
3)Difference between char const *p, const char *p,const * char p, const char * const p
4)What Is FILE *fp
5)Write a program to print a file from the last .
6)Write a program to encrypt the file
7)What is abstraction
8)What is run time polymorphism
9)What is register storage class? If a variable is declared as register then is it compulsory that it will be of storage type register?
10)What is interface in java ?
11)What is implementation ?
12)Why java doesn’t support multiple inheritance ?
13)Is c++ is pure object oriented?
14)Why we need new operator in java at the time of object declaration and why not in c++?
15)Write a program to implement virtual functions ?
16)What is the difference between file and data base storage ?
17)Difference between hierarchical data model and network data model ?
18)What are the 12 codd’s rule ?
19)Gave me a table and asked me to normalize it up to 3 nf ?
20)Difference between BCNF and 4 nf ?
21)Difference between conflict and view serialzability
22)What is batch operating system ?
23)Difference between multiprogramming and multitasking ?
24)What are different types of scheduler ? explain short term scheduler ?
25)What are different scheduling algorithms ?
26)What is a system call?
27)Monitors and Semaphores ?
28)What are different CPU registers ?
29)Object oriented model, Component Assembly model and Waterfall model ? compare them ?
30)Difference between OSI and TCP/IP?
31)X.25 ?
32)CSMA/CD ?
33)IEEE?
34)Heap Sort, Merge Sort ?
35)Hashing Technique ?

I was thinking that, “yaar kintne question poochenge ye log, voh poochte ja rahe the aur main batataja raha tha”, there were lots of other question..

This round lasted for around 50 -55 mins and HR round was also attached to this because we were only 5 people selected out there, now came the time for the HR interview:

Normal Questions:

1)Describe Yourself as a person ?(she said I don’t want u to repeat the resume, something which in not mentioned in that)
2)Say something about dream.. I said, “Dream as if you’ll live forever, live as if you’ll die today.”
3)Which is your dream company ? I said that, “I m telling u the truth, my dream company is Google”, then she asked me why Google, I was well prepared for that question I said, “God is with them who have the courage to fly, not with them who stand on the ground and watch the sky”, then wla wla wla…
4)Then why Zensar ? “One of the greatest victories you can gain over someone is to beat him at politeness”, that’s what I have done at that time
5)Where do you see yourself after 5 years ?
6)Say something on,”when you are in Rome do what Romans do” And that’s it, finally me and three of my friends were selected in the ZENSAR. At last I want to say that, “Courage doesn’t always roar. Sometimes courage is the quiet voice at the end of the day saying, “I will try again tomorrow.”

So if you are not selected don’t worry coz “after every sad day there comes the glad day”