Saturday, 22 September 2012

MICROSOFT PLACEMENT PAPERS 2011


microsoft aptitude test 2011
10 MCQ's----------------Time : 30min
1Q.
int rec(int i)
{
static int d=1;
if(i>=5)
return i;
d=d+i;
i=i+i;
rec(d);
}
Find f(1) ?
2Q.
int fun(int j)
{
int i,y;
if(j<5)
return j;
for(i=0;i<3;i++)
y+=fun1(j/3);
return y;
}
int fun1(int k)
{
int i;
if(k<5)
return k;
return 3*fun(k/3);
}
which of the following are correct
a. Recursion never terminates
b.y in fun uses garbage value
c.loop in fun is useless
d. -----
1)a,b,c,d 2)b,c 3)b 4)None
3Q.
Given inorder and postorder for a tree. (.......i forget the exact
nodes....)
Find root and leaf nodes for the tree.
4Q.
#include
main()
{
int a[2][3]= { (1,2,3),(4,5,6)};
int (*ptr)[3] = &a[0];
printf("%d %d\n", (*ptr)[1],(*ptr)[2]);
ptr+=1;
printf("%d %d\n", (*ptr)[1],(*ptr)[2]);
}
what is the output of the program
1.segmentation fault 2.compiler error 3.---- 4.-----------
(----------TWIST:correct answer not given in options,may be they want us to
write the correct answer).
5Q.
In a 4GB addressable system, how much memory the following pointer occupies
in the STACK.
char *p=NULL;
1.4 bytes
2.8 bytes
3.Pointer memory wont be allocated in stack, it will be allocated in heap
4.No memory will be allocated untill it is initialized using malloc()
6Q.
which statement is true about following pointer
char **p=NULL;
1.---------
2.----------
3.No memory will be allocated for *p,p in stack, but memory **p will be
allocated in stack.
4.No memory will be allocated for p in stack, but memory **p,*p will be
allocated in stack.
7Q.
very similar question as 2Q (about static variables).
8Q.
To find the roots for an exp. ax^2 +bx+c=0, a prg. will test following cases
a.if a=0 then roots wont exist
b.if b^2-4ac=0 then single root will exist
c.if b^2-4ac>0 then multiple roots exist
d.if b^2-4ac<0 then imaginary roots exist
certain test cases are given. as
i) a=..,b=..,c=..
ii)a=..,b=..,c=..
iii)..........
iv).......
v)..........
vi)...........
vii)..........
1. (ii,i,iii,iv) 2. (i,iii,iv,vi) 3------- 4---------
We have to find out the minimum test case set from options,which cover all
the four given cases
9Q.
void swap(int a,int b)
{
int t;
t=a;
a=b;
b=t;
return;
}
To swap variables using above function, how the arguments should be passed.
1.swap(x,y)
2.swap(&x,&y);
3.Above swap function cant be used to swap variables
4.None of the above
10Q.
for(x=n,y=-1;x>0;x=x/2,y=y+1);
After the execution of above statement what would y contain
1.f(log(n))
2.f(sqrt(n))
3.f(n)
4.f(nlogn)
WRITTEN TEST -------2 TIME : 45min
1. A string is given such that all characters are in ascending order and
also from [a-z] and the difference between consecutive characters is 1 only,
but one(only one) substring is manipulted in decreasing order. we need to
correct it to ascending order.
Eg: i/p: abcfedgh
o/p: abcdefgh
2.Write test cases for end-to-end functionality in p2p network.
3.Design a file sync system, such that it contain centralized database
server and some files are shared at each client. Change in file at one point
by one client much reflect at all clients. And there may be different files
shared by different clients with server. So, server needs to maintain a
state per client which contain corresponding client files sharing data,etc.
And clients cant be always in online. And sometimes changes made by clients
cant be updated succesfully due to network problems, in those cases
modification shouldn't be done.
Design a system of above features. If u want,you can design a state machine
and specify the transitions clearly to carry out the above functionalit

No comments:

Post a Comment