With binary search, you can find out the minimum number of turns you need to take in order to find the number. But in this matter, the value that you should think about is not number of turns, but rather min sum that you pay in worst case, which is determined by partif you guess wrong, you pay $x
Here is an example where binary search will not be performed:
[1,2,3,4]
Using BS in the worst case
pick(2) -> decision: target is bigger
-> pick(3) -> decision: target is bigger [if decision is smaller thats not worst case]
-> pick(4) -> done
Total cost = 2+3 = 5
In an optimal strategy:
pick(3) -> decision: smaller [if decision is bigger thats not worst case]
-> pick(1) -> decision: bigger [if decision is smaller thats not worst case]
-> pick(2) -> done
Total cost = 3+1 = 4
, . , , , , DP.