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???

You can make it easier to think about by pretending the number is between one and ten. The algorithm is identical.

Just 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?

It will be Binary Search
And Also 1000000 = 2^30
So Questions will be Log(2^30) = 30

kindly someone to guide that instead of binary search..cant it be done with recursion???

This question has already been answered. Start a new discussion instead.