The array A of size n=31 is sorted in non-decreasing order (0s followed by 1s).
The number of zeros in the array can range from 0 to 31. Therefore, there are 31+1=32 possible configurations for the index of the first occurrence of 1 (including the case where there is no 1).
Each probe (comparison) at an index tests whether the value is 0 or 1, which gives a binary outcome and partitions the remaining search space into two parts.
By information theory, any comparison-based algorithm represented by a binary decision tree with K possible outcomes requires at least ⌈log2K⌉ probes in the worst case:
Worst-case probes=⌈log2(32)⌉=5 An optimal binary search algorithm can always find the transition point in at most 5 probes.
Thus, the worst-case number of probes is 5 [cite: 2].