Please Help
Example: Found the team with index 2:
\(\begin{array}{|lcll|} \hline 1. \text{Search: team index } \le 16 \qquad | \qquad \text{yes} \\ 2. \text{Search: team index } \le 8 \qquad | \qquad \text{yes} \\ 3. \text{Search: team index } \le 4 \qquad | \qquad \text{yes} \\ 4. \text{Search: team index } \le 2 \qquad | \qquad \text{yes} \\ 5. \text{Search: team index } \le 1 \qquad | \qquad \text{no} \\ \mathbf{6.} \text{Search: team index } = 2 \qquad | \qquad \text{yes and found} \\ \hline \end{array}\)
In the worst case 6 items. At most, 6.
You should be able to find the item in no more than 6 tries.
First ask if the item is above half-way. Whatever the answer you have reduced the search space so that you now only have 16 items to search. Whichever 16 it is, choose the middle of them and ask if the item is above or below this position. Now the answer will reduce the search space so you only have 8 items to search. Continue in this way until there is only one possibility left.
Please Help
Example: Found the team with index 2:
\(\begin{array}{|lcll|} \hline 1. \text{Search: team index } \le 16 \qquad | \qquad \text{yes} \\ 2. \text{Search: team index } \le 8 \qquad | \qquad \text{yes} \\ 3. \text{Search: team index } \le 4 \qquad | \qquad \text{yes} \\ 4. \text{Search: team index } \le 2 \qquad | \qquad \text{yes} \\ 5. \text{Search: team index } \le 1 \qquad | \qquad \text{no} \\ \mathbf{6.} \text{Search: team index } = 2 \qquad | \qquad \text{yes and found} \\ \hline \end{array}\)
In the worst case 6 items. At most, 6.