Interview Questions

If I were to ask this question, I would ask it exactly as I framed it above. Regardless of the path the candidate chose, I would expect them to be able to give reasons why they chose that path. However, if you gave me the binary search answer and simply told me that it is the best because it has the fewest number of weighs in it, I would simply look at you and say, “I believe I can solve it faster with more weighs”.

I never even thought of binary search. I think it’s the same reason I don’t much worry about indexes on a table that will ever only have say 8 rows. Give me 8 balls I compare them two at a time. Give me 10,000 balls and I’ll approach the problem differently. But then how long does it take to load 500 balls onto a big scale - and are there smaller weight variances amongst the “identical” balls that could throw off comparisons at that scale? You’d hope the tolerances + averages would solve that for you, but who knows.

I think the problem is kind of silly but then I also think interviews are kind of silly too. I’d hate to be judged on an answer to this question in a vacuum, because I’d have answered it “weigh them two at a time”. So I agree you can learn a lot more by having a discussion about the answer and how someone arrived at it rather than looking at the exact answer given.