Home »» Placement Papers »» All Papers »» Microsoft »» Placement Paper



1. If you are on a boat and you throw out a suitcase, Will the level of water increase.

2. Print an integer using only putchar. Try doing it without using extra storage.

3. Write C code for (a) deleting an element from a linked list (b) traversing a linked list

4. What are various problems unique to distributed databases

5. Declare a void pointer 

ANS. void *ptr;

6. Make the pointer aligned to a 4 byte boundary in a efficient manner 

ANS. Assign the pointer to a long number and the number with 11...1100 add 4 to the number

7. What is a far pointer (in DOS)

8. Describe the file system layout in the UNIX OS

  9. describe boot block, super block, inodes and data layout

10. In UNIX, are the files allocated contiguous blocks of data

ANS. no, they might be fragmented

11.How is the fragmented data kept track of

ANS. Describe the direct blocks and indirect blocks in UNIX file system

12. What is a volatile variable?

13. What is the scope of a static function in C ?

14. What is the difference between "malloc" and "calloc"?

15. struct n { int data; struct n* next}node;
node *c,*t;
c->data = 10;
t->next = null;
*c = *t;
what is the effect of the last statement?

16. If you're familiar with the ? operator x ? y : z
you want to implement that in a function: int cond(int x, int y, int z); using only ~, !, ^, &, +, |, <<, >> no if statements, or loops or anything else, just those operators, and the function should correctly return y or z based on the value of x. You may use constants, but only 8 bit constants. You can cast all you want. You're not supposed to use extra variables, but in the end, it won't really matter, using vars just makes things cleaner. You should be able to reduce your solution to a single line in the end though that requires no extra vars.

17. How do we test most simply if an unsigned integer is a power of two?
ANS. #define power_of_two(x)  ((x)&&(~(x&(x-1))))

18. Set the highest significant bit of an unsigned integer to zero.
ANS. (from Denis Zabavchik) Set the highest significant bit of an unsigned integer to zero
#define zero_most_significant(h) 

19. Let f(k) = y where k is the y-th number in the increasing sequence of non-negative integers with the same number of ones in its binary representation as y, e.g. f(0) = 1, f(1) = 1, f(2) = 2, f(3) = 1, f(4) = 3, f(5) = 2, f(6) = 3 and so on. Given k >= 0, compute f(k).

20. A character set has 1 and 2 byte characters. One byte characters have 0 as the first bit. You just keep accumulating the characters in a buffer. Suppose at some point the user types a backspace, how can you remove the character efficiently. (Note: You cant store the last character typed because the user can type in arbitrarily many backspaces)

21. What is the simples way to check if the sum of two unsigned integers has resulted in an overflow.

22. How do you represent an n-binary tree? Write a program to print the nodes of such a tree in breadth first order


0 Answers