3 ms·
idle thought, given 20 questions you can ask any questions that can be answered with a yes or no, what would the smallest number of questions to guess a number
by keithnz 4y ago
idle thought, given 20 questions you can ask any questions that can be answered with a yes or no, what would the smallest number of questions to guess a number between 1 and a million?
- hobos_delight 4y agoI don't think you can do better than a binary search here, so log2(1000000) questions, which happens to come out to 20 with rounding. I tried thinking a bit outside the box for other questions that would break down the search space - but none of them were any improvement on the binary search.