Interview Question

Applications Engineer Interview

-

Oracle

You have 2 light bulbs. You are in multistory building such that if you drop a bulb from a floor of a certain height or higher the bulb will break: for ex: if the bulb will break at a minimum height of 10th floor, then the bulb will break if dropped only if dropped from a floor higher than tenth floor. it will not break if dropped from ninth floor or less. using the two bulbs how will you figure out at which floor will the bulb break?

Tags:brain teaser
AnswerAdd Tags

Interview Answers

14 Answers

4

I forgot to mention that you have to try to figure out the floor in the least amount of tries. so incase the minimum floor is 100, you shouldn't try all the floors. The solution posted above works, but is the least efficient.

poster of the the question on

8

With 2 bulbs we can skip 3 floors at a time. 1) Drop bulb #1 at floor x 2) If it breaks then try floor x-1 else try floor x+3 Start with floor 1.

Gaurav on

1

The issue with a research-based answer is that parameters of the posed problem is not based in reality, i.e. dropping a light bulb from any floor would almost guarantee it breaking in real life. So the interviewer is really looking for problem solving skills for an hypothetical situation rather your attention to detail in a real world situation.

Z on

1

it depends the speed and the force it is doped

Anonymous on

0

release on bulb from nth floor and other one you throw up till n+1 floor upwards! you can check for 2 floors at a time! would like your inputs

Anonymous on

0

@Keshav: What if first bulb breaks at n/2, then according to binary search the next bulb will be dropped at n/4 as u mentioned. What if the second bulb breaks at this point. You dont have any bulbs left to find to out if the threshold is lesser than that????

Anubhav on

1

You start with the n/2 floor. After that you go one by one from either 1 or n/2 +1 until it breaks. If it does not break at n/2 you can go to 3n/4 and try. depending on floor this will either save or possibly add one additional drop. This always gives you Floor + 2 drops (or Floor - n/2 + 2 drops if it is a high floor)

MV on

0

1. Start with the 13th floor. If it breaks, start checking sequentially from floor no. 1 (1, then 2, then 3, and so on) 2. If it doesn't, go to the 13+12th floor = 25th floor. Then to the 25+11th floor = 36. Then 46, 55, and so on. If the egg breaks at, let's say the 55th floor, starting checking for the 46th, 47th, 48th (...) floor till the 54th one. The advantage of using this procedure is you're able to find out the exact floor in a maximum of 13 steps.

Shubham Goel on

0

I guess the bulb would break from 1st floor itself :p

Anonymous on

0

Assuming no of floors = A, tester can escape x floor at a time e.g. if x = 10, test at 10, 20,30... If 1bulb breaks at 20, test from 11 to 19. So solution is minimum of (A/x + x-1) using derivatives x=√A is for minimum i.e. min value is A/√A +√A -1 =2√A-1. Example for 100 floors minimum is 19

Anonymous on

0

Start from floor 1, drop the bulb. If it breaks, then it tells you that at any floor the bulb will break. But, if it doesn't use the same bulb to test its survival on n+1 floor. By continuing this you will reach a floor where the bulb breaks. Hence, you identified the floors where the bulb breaks (BFloor) and the floor where it doesn't (BFloor-1), also you have saved a bulb for use.

Anonymous on

0

use they way u use binary search. STEP 1:divide number of floors(n) by 2 = n/2 , drop it there STEP 2: if it breaks, repeat step 1 taking n= n/4 STEP 3: if it doesn not break, drop it next at n=3n/4 refer BINARY SEARCH

Keshav on

0

Those examples listed are good solutions, but if you wanted to make a bold attempt at wowing them, then here's one answer. This one allows you to save both bulbs and conserve them, which is why I think this answer has a potential wow'ing factor! It's also the answer I would give as a supplemental...it's pretty outlandish for it to stand as your only answer. Using the two bulbs you'll know the make and model. Retrieve the information from the manufacturer that gives data on the physical characteristics, i.e. stress, that the light bulb's glass can take. Then make a calculation that tells you at which height will that stress be reached if you were to drop a bulb from that height. You can also figure out the influence from the material the floor is made of. After that, you go home into your apartment and put those light bulbs back where you found them haha

Kunal on

4

Keep going from floor to floor starting from 1 to 2 to 3 and so on.....the first bulb will break at the threshold. So you basically don't even need the second bulb to decide which is the critical floor.

Amit from HSBC on

Add Answers or Comments

To comment on this, Sign In or Sign Up.