## Interview Questions 11

August 7, 2010 3 Comments

1. Given 10K of 16bit integers and unlimited memory, find most efficient algorithm that counts number of bits set to 1.

2. Print the pascal triangle. Don’t worry about formating.if i/p is 1 then print first line. if 2 then print 2 lines of triangle.see wiki about pascal triangle.

3. Print elements that are in a vertical column (per column) in a Binary tree

4. Given customer vs visited pages log for three days, find the customers who have visited for exactly 2 days and visited page count > 2. Customer can visit the same page any number of times.

5. How to represent a map of large nodes and edge in memory

6. Palindrome Date: A date is said to be a palindrome when it is expressed in MMDDYYYY format, it reads the same both ways. Given 2 years as input(ex: 2000, 2010), print out all the dates which are palindrome dates.

7. You are given a sets of words ,Write a C code which output the anagrams sets.

Eg for Input: algorithm testing asdfgh esttngi gorialmth

Output:

algorithm gorialmth

testing esttngi

8. Write a preorder traversal of a binary search tree w/o recursion / stack / extra memory storage. Hint – you can augment the node data structure. However, you can’t add a visited field to the node.

9. How will you remove white space from a string?

10. Prove that you can’t build a random number generator function that will output numbers 1 to 7 with uniform distribution and guaranteed to work in finite time using a random number generator that outputs either 1 or 2 with equal probability

11. An array is given like {1,4,5,2,3,6,7}. sort the odd elements in descending order and even numbers in ascending order. so result would be {7,5,3,1,2,4,6}.

## Recent Activity