Blog # 19 : Microsoft Placement Paper : Objective
1. Given a string s[1...n] and a reverse function reverse(s, i, k)
which reverses the character sequence from i to k (inclusive of both)
in string s, determine what the following operations result in.
1<k<n
reverse(s, 1, k)
reverse(s, k+1, n)
reverse(s, 1, n)
a) Reverses the string
b) Rotates the String left k positions
c) Rotates the String right k positions
d) None of the above
Answer: b)
2. If len is the length of the string and num is the number of characters printed on the screen. Give the relation between num and len.
void abc (char *s){
if(s[0]=='\0')
return;
abc(s+1);
abc(s+1);
printf("%c ", s[0]);
b )num=2^len-1
c) num=2*len-1
d) None of the above
Answer: b)
3. Which of the following numbers cannot be represented accurately in binary?
a) 0.1 b) 6.5 c) 1/16 d)1.32 e) 0.590625 (not sure abt option e)
1. a only
2. a and b
3. a, b and d
4. a, b and e
Answer: a) and d) should be the answer
4. A process doesn't require additional processors to carry out 40% of it's execution since 40% is mostly sequential. Determine how many processors are required to execute the process in 150s if
the process takes 300s to execute on a single processor.
a)5
b)8
c)6
d)7
Answer: c)
5. Time complexity of a function f(m) is O(m). If the array[i...n] contains either 1 or 0 in each of it's locations, determine the worst case time complexity of the following piece of code written in C-like
language.
counter=0;
for(i=0; i=n; i++){
if(a[i]==1)
counter++;
else{
f(counter);
counter=0;
a) O(n^2)
b) O(n^2 logn)
c) O(nlogn)
d) O(n)
Answer: d) if assuming everything else to be alright.
6. Increasing the RAM increases the efficiency of the CPU. The reason
is
a) Virtual memory increases
b) Number of page Page faults decreases
c) Page segmentation decreases
d) Increasing the amount of memory increases the speed of fetching
data.
Answer: b)
7. If a dice is thrown three times, what is the probability that a "six" comes atleast once.
a) 125/216
b) 25/216
c) 91/216
d) 1/216
Answer: c)
1<k<n
reverse(s, 1, k)
reverse(s, k+1, n)
reverse(s, 1, n)
a) Reverses the string
b) Rotates the String left k positions
c) Rotates the String right k positions
d) None of the above
Answer: b)
2. If len is the length of the string and num is the number of characters printed on the screen. Give the relation between num and len.
void abc (char *s){
if(s[0]=='\0')
return;
abc(s+1);
abc(s+1);
printf("%c ", s[0]);
}
a) num=2^len
b )num=2^len-1
c) num=2*len-1
d) None of the above
Answer: b)
3. Which of the following numbers cannot be represented accurately in binary?
a) 0.1 b) 6.5 c) 1/16 d)1.32 e) 0.590625 (not sure abt option e)
1. a only
2. a and b
3. a, b and d
4. a, b and e
Answer: a) and d) should be the answer
4. A process doesn't require additional processors to carry out 40% of it's execution since 40% is mostly sequential. Determine how many processors are required to execute the process in 150s if
the process takes 300s to execute on a single processor.
a)5
b)8
c)6
d)7
Answer: c)
5. Time complexity of a function f(m) is O(m). If the array[i...n] contains either 1 or 0 in each of it's locations, determine the worst case time complexity of the following piece of code written in C-like
language.
counter=0;
for(i=0; i=n; i++){
if(a[i]==1)
counter++;
else{
f(counter);
counter=0;
}
}
* i=n was given in the condition of for loop
}
a) O(n^2)
b) O(n^2 logn)
c) O(nlogn)
d) O(n)
Answer: d) if assuming everything else to be alright.
6. Increasing the RAM increases the efficiency of the CPU. The reason
is
a) Virtual memory increases
b) Number of page Page faults decreases
c) Page segmentation decreases
d) Increasing the amount of memory increases the speed of fetching
data.
Answer: b)
7. If a dice is thrown three times, what is the probability that a "six" comes atleast once.
a) 125/216
b) 25/216
c) 91/216
d) 1/216
Answer: c)






