Solution: If you are in a boat, inside of a giant cup which is half-filled with water -- and you throw something from inside the boat into the water, does the water in the cup go up or down?
Let's start with a picture of what this looks like to make sure that understand the problem. Pic 1 shows the problem. There is a boat, afloat on water inside a giant cup.
Now, let's jettison something off of the boat. What happens?
The first thought is that his has to do with buoyancy and how objects float. It's ok to ask the interviewer about buoyancy (I did in fact in an interviews). The most relevant answer here is Archimedes' principle which is:
Any floating object displaces its own weight of fluid.
Well, let's think about this. If we throw something off of the boat, it will displace water equal to its own weight. However, we also know the boat will now also do something different as it has less weight on it.
If you're really good at thinking abstractly, you can actually work Archimedes' principle to the correct answer, but I'm just stuck in theoreticals. When this happens, it's best to go to an example.
Let's assume that we throw something really really heavy and dense off of the boat. (this is a hint too)
Imagine that we throw an anchor off the boat.
Well, intuitively, the boat will come up as it is now carrying less weight of cargo (think of an empty oil tanker rides higher). This is consistent with Archimedes' principle as the boat no longer needs to displace as much water as it weights less.
This one phenomena would result in the water going down in the glass (think of putting your hand in a glass of water and pulling it out).
However, the anchor will displace water which will make it rise (think of putting a big rock in a bucket and seeing it rise).
So, the outcome will depend on whether the water going down will net out more or less against the water going up.
Well, what is it?
Archimedes' will get you here, but often, it's easier to think of a more extreme example if the answer isn't yet clear. Assume that you threw something super heavy off the boat -- like a pea sized amount of a super-dense star.
The result would be that the boat comes up as it is lighter, and the water drops. In the meantime, the pea-size star displaces almost no water, so the net is the water goes down.
This is one possibility. Now, think through if this works for the anchor. In the case of the anchor, the boat goes up, which the anchor displaces water. However, if the anchor displaced as much water as the boat did, it would not sink. So, you can start to see the general pattern that if any object sinks, then the water goes down in the cup.
Now, let's think of if the object floats. Well, this is the special case where the boat goes up causing the water to go down, while the object displaces just enough water to float, which is the same as the amount that it used to displace when it was part of the floating boat. So, there is no change in the water level.
So, the answer is:
- if the object floats, the water level is the same
- if the object sinks, the water level goes down
This is a good example where the most useful insight came out of an extreme example. Then, we could work backwards and apply principles to quickly solve the problem. One take away is to try to solve a brain-teaser for any case, which can then provide lots of insights.
/* Please let me know if you have other thoughts or find bugs in the solution. Thx, Noah */
Code WorkOut of the Day -- Daily exercises for programmers looking for jobs, or just to keep sharp with skills and have fun. I give talks, like this: https://youtu.be/NpvTE7GlXSM for people looking for jobs, or groups of programmers preparing for M&A tech HR due diligence. Follow us on twitter: @codewod
How to
When solving these problems, learning by doing is much better than learning by reading. I encourage to you read only as far in the solution as you need, then trying to solve the problem. If you get stuck, try reading a little further. And of course, let me know if you find a better solution!
Interesting question. However Archimedes' principle is known to not account for surface tension. So I believe your solution is incomplete. To be fully correct a solution should ad least mention surface tension.
ReplyDeleteAfter some further thought (and I'm still annoyed I didn't get this), doesn't the answer assume that the volume of the object thrown off the boat is smaller than the volume of water displaced by the boat weighing more? So perhaps it should be: if the object sinks but is smaller than the water displaced by the heavier boat, water level goes down; if the object sinks but is the same size as the water displaced by the heavier boat, or the object floats, water level stays the same; if the object sinks but is larger than the water displaced by the heavier boat, water level goes up.
ReplyDelete