### Collection of Technical Interviews Questions

Collection of Technical Interviews Questions

1. You are given some long text string such as
“This text has many words. Which word occurs the most in the text?”

Write a program which finds the word that appears most frequently in the text. If there is a tie then your program must return the word that appear first in the text.
2. Given a set of banks (classes) each with a different function for updating an account, with possibly different parameters, how do you get a single function to call the appropriate method on each type.
3. Can a Java class have a data member of the same type as that Java class?
4. How does Java implement garbage collection?
5. How big is a reference in Java?
6. Given two long strings, find the largest common substring in O(n log n) time.
7. Given a histogram (height of each bar and the common width of all bars) find the biggest rectangle that can be drawn such that every point in the rectangle lies above a bar, that is, the rectangle only covers parts of the histogram and none of the background.
8. There are three pizzas: one burned on both sides, one burned on one side, one not burned. They are randomly stacked and you see that the side at the top is burned. What is the probability that the other side of the top is not burned?
9. Implement the software for a coke machine.
10. What is the difference between a class and an object?
11. You are given a function which generates a random number from the set 1,2,3,4,5 each with equal probability. Use this function to implement another function which generates a random number from the set 1,2,3,4,5,6,7 each with equal probability.
12. Imagine you have two marbles and a 100-story building. You are told that the marbles will break if they are dropped from a certain floor. Figure out a way, as effectivly as possible, how high you can drop the marbles before they break. Remember, it could be the 1st floor, it could be the 99th.
13. Let's say you have a computer with 2M RAM. This computer has a hard drive (with lots of free space) and a 100M file which you should sort. Let me know how you, as effectivly as possible, sort the file.
14. We take the computer from the previous question and replace the hard drive with a network adapter. You have no local storage but the RAM. You will receive one million eight-digit phone numbers through a TCP stream which you shall sort in RAM. You are now allowed to send any data before all the numbers have been sorted. How would you solve this?
15. Suppose I give you a phonebook and ask you for a name, how long would that take?