Though in Question it is not Clearly said that whether Mary asks to Bob that chosen number is lesser or greater (which was written by Bob)
But in question it is clearly said that Mary uses optimal strategy, Mary would have done like below mention approach:
(Mary chooses a number and asks to Bob whether is it right number, if Bob answers YES or NO.(assume Bob answers NO for worst case condition) Then again Mary asks to Bob whether is it greater?, Bob can answer YES or NO. If Bob says YES then Mary divides the Chosen number by 2 else multiply by 2 something like this....in recursive way)
Hence it is like Binary Search Algorithm and Mary asks two questions in each step:
In worst Case total question asked by Mary = 2 x log2(1000) ≈ 20
But in Option Answer is given assuming Mary asks questions only one time in Each Step...!