MICROSOFT INTERVIEW QUESTIONS 2011

ROUND 1 :

Written Test Questions :

(1)  Give the output of the following program

        int main
    {
             char ch[]={‘1’,’2’,’3’,’4’,’5’};
             char *p = (char *)(&ch+1);
            char *q = &ch+1;
           printf(“%d     %c    %c”,sizeof(ch),*(p-1),*q);
       }
(2)
     int main
    {
double i=2.0,j=1.0,sum=0.0;
  while(i/j>0.001)
  {
      j=j+j;
      sum=sum+(i/j);
      printf("%f\n",sum);
  }
    }
The question here is : For how many steps this while loop will run and
what would be the best approximate value of the sum after the loop
ends .

(3)    TOC question
    Given a grammar
s->AB
A-> a | BaB
B->bbA
Which of the following statement is false ?
a.    Every string  will be of even length .
b.    Every string  will not have three consecutive a’s .
c.    Every string will not have four consecutive b’s .
d.      Every string will have at least as many a’s as there are b’s

(4)   You are given a disk  where ‘1’ represents a occupancy of a
sector and ‘0’ represents vacancy of a sector  ....given a hexadecimal
string DFE00454AB which represents the various sectors ... find the
nearest percentage of occupied sectors ?

(5)  Find the output
int arr[2][3]={{1,2,3},{4,5,6}};
int (*ptr)[3]=&a[0];
printf("(%d,%d)",(*ptr)[1],(*ptr)[2]);
ptr+=1;
printf("(%d,%d)",(*ptr)[1],(*ptr)[2]);

    Will this program compile properly or will end in segmentation
fault ??
(6)
double full(double a)
{
   return (int)(a+0.5);
}

does this always work??

(7) int x=123,y=231;
   int t=0;
   int l;
   l=x^y;
   while(l)
   {
       t++;
       l&=l-1;
   }
   printf("%d",t);

(8) char str[80];
     strcpy(str,"junk");
     scanf("%[^india]",str);
     printf("%s",str);

         What will be the output of this code snippet if the given
input is “Gujarat”?

(9) Given a inorder traversal eg 1 2 3 4 5 6 7 8 9 , Check which of
the following preorder traversal will it return .
    a.    1 6 3 2 7 8 4 9
    b.    6 7 3 8 1 9 2 7
    c,    2 4 6 8 1 3 5 7
    d.    1 3 5 7 2 4 6 8


(10)     main()
{
int j=12,i=15;
i*=j-2 ;
j&=j-1;
printf(“%d %d”,i,j);
}
         Write the output.

Algorithm and Data Structure Design

1. Find gcd of 2 numbers U & V in O(log UV)^2 .

2.   Test cases for finger print reader say in a laptop to login .
Here you can swipe your finger to have a secured login .
    eg . I will swipe my finger and the system will allow me to
login  .

3. Design question......for billing , u have barcode, barcode
number,item price, taxes, discounts for items (some criteria were
given and u have to  design an algo for calculating discount) and then
finally compute Net price....what DS u ll use....how ll u improve this
design...State advantages and disadvantages of any alternative
solutions.....

Calculating discount :
a.) If you buy X quantity of the item P , then you can buy other item
Q for free (X,P,Q are specified).
b.)If you buy any item P for price X , then you can buy other item Q
for free (X,P,Q are specified).
c) If there are multiple discounts available then apply all those .

Interview experience (Prasanth cse reg)

ROUND 2 :

1.Write a function that returns the result of merging two sorted
linked lists . And find the time complexity of your proposed
solution .

ROUND 3 :

1.Do the same merging recursively if an iterative solution was given
in round 2 or the other way.

2. Given a preorder traversal build a valid binary search tree. Write
code covering all possible cases.

3. Let “E:\dir1\dir2\..\..\dir3\page.html” be the file required. Here
“.. “ tells us that we should move one directory to the back.So the
final output should be “E:\dir3\page.html”. So write code for this
covering all end conditions and do this in place if input is given in
an array.

ROUND 4:

1. Find the closest ancestor any two nodes in a binary search tree.
Write code for this.( Dont forget to check the end conditions or base
cases ).

2.Give a string with spaces how will u compact it. Give various
possible inputs for this. Optimise ur code .

3.Given two arrays with one array containing m elements sorted and
another array of size m+n containing n elements sorted at beginning
where the last m positions are empty, write code to merge these two
sorted arrays efficiently so that u have the entire sorted elements of
the two arrays in the bigger array.

4. Why java is platform independent? (They expected something other
than bytecode and portability)

Interview experience (Anuja cse reg)

Round 2:
1.Removing duplicates in an array
2.Removing d characters in Fibonacci position in a string and
compacting it.
3.Finding closest parent in a binary tree.
Round 3:
1.Given a list of methods in java, some are unsafe. U r provided wit a
method ‘isUnverifiable’ tat takes a method and returns true or false
based on whether the method passed is safe or unsafe. Write a code the
takes in an array of method and outputs an array of unsafe methods.
(Note: A method is said to be unsafe when ‘isUnverifiable’ returns
false or it is called by another unsafe method) Give 10 testcases.
2.Some basic ques about java
Round 4:
1.Placing Rooks in a chess board
2.How malloc and free are implemented , how os deals wit them, etc.
3.Some basic ques in OS
Round 5:
1.When u compile and run a high level lang prog, wat happens in the
computer.( Explain everythin from lexical analysis, syntactic,
ICG,code optimization, code gen, then paging, caching, pipelining,
interrupts, polling, instruction sets, ALU... )
2.Wat will happen to d level of water when u drop a suitcase from a
boat
3.y man hole covers are circular in shape .
4.Check for duplicates in an unsorted array in O(n) without using any
extra space

In all the rounds there were ques from the projects . For each
program, test cases were asked.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to