Home /
Expert Answers /
Computer Science /
nbsp-think-a-number-bob-and-alice-play-a-game-in-which-bob-gives-alice-a-challenge-to-think-of-pa947
(Solved):
Think a Number Bob and Alice play a game in which Bob gives Alice a challenge to think of ...
Think a Number Bob and Alice play a game in which Bob gives Alice a challenge to think of any number \( \mathrm{M} \) between 1 to \( \mathrm{N} \). Bob then tells Alice a number \( \mathrm{X} \). Alice has to confirm whether \( \mathrm{X} \) is greater or smaller than number \( M \) or equal to number M. This continues till Bob finds the number correctly. Your task is to find the maximum number of attempts Bob needs to guess the number thought of by Alice. Input Specification: input1: \( N \), the upper limit of the number guessed by Alice. \( (1<=N<=108) \) Output Specification: Your function should return the maximum number of attempts required to find the number \( M(1<=M<=N) \). Example 1: