if i were asked a secret question between 1 and 1 billion by asking yes/no question of the form "is the number less than X?
" what algo should i use to efficiently find the secret number?
using the algo what will be the minimum number of questions if asked will guarantee to find
the secret number???
Builder_1
-6
Junior Poster in Training
Recommended Answers
Jump to PostYou can make it easier to think about by pretending the number is between one and ten. The algorithm is identical.
Jump to PostJust think of the number in in its binary representation.
What question will tell you the value of the first bit?
Knowing that, what question will tell you the value of the next bit?
How many questions will you need to know the values of all the bits?
All 6 Replies
Moschops
683
Practically a Master Poster
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
umairs007
0
Newbie Poster
Builder_1
-6
Junior Poster in Training
Builder_1
-6
Junior Poster in Training
SalmiSoft
102
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.