We are given a bitonic array $A[1..n]$ of distinct integers: it strictly increases to a unique peak and then strictly decreases. The goal is to determine the worst-case number of comparisons required to search for a given key.
The optimal strategy consists of two phases:
- Locate the peak element using a modified binary search.
- Perform binary search in the increasing and/or decreasing segment.
Both phases run in $O(\log n)$ time, and a matching $\Omega(\log n)$ lower bound holds, yielding $\Theta(\log n)$.
We illustrate the process with the example array:
\[
A = [2,\ 5,\ 8,\ 12,\ 15,\ 13,\ 10,\ 6,\ 3], \quad n = 9.
\]
The array with indices is represented as:
\[
\begin{array}{c|ccccccccc}
i & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline
A[i] & 2 & 5 & 8 &12 &15 &13 &10 & 6 & 3
\end{array}
\]
We search for the key $x = 10$.
$\textbf{Phase 1: Find the peak index}$
We maintain pointers $\texttt{low}$ and $\texttt{high}$, initially $\texttt{low}=1$, $\texttt{high}=9$. At each step, compute $\texttt{mid} = \lfloor(\texttt{low}+\texttt{high})/2\rfloor$, and compare $A[\texttt{mid}]$ with $A[\texttt{mid}+1]$.
$\textit{Iteration 1:}$
\[
\texttt{low}=1,\quad \texttt{high}=9,\quad \texttt{mid}=5
\]
\[
\begin{array}{c|ccccccccc}
i & 1 & 2 & 3 & 4 & \color{blue}{5} & \color{red}{6} & 7 & 8 & 9 \\ \hline
A[i] & 2 & 5 & 8 &12 & \color{blue}{15} & \color{red}{13} &10 & 6 & 3
\end{array}
\]
Since $A[5] = 15 > 13 = A[6]$, we are on the decreasing side. Set $\texttt{high} \gets \texttt{mid} = 5$.
$\textit{Iteration 2:}$
\[
\texttt{low}=1,\quad \texttt{high}=5,\quad \texttt{mid}=3
\]
\[
\begin{array}{c|ccccccccc}
i & 1 & 2 & \color{blue}{3} & \color{red}{4} & 5 & 6 & 7 & 8 & 9 \\ \hline
A[i] & 2 & 5 & \color{blue}{8} & \color{red}{12} &15 &13 &10 & 6 & 3
\end{array}
\]
Since $A[3] = 8 < 12 = A[4]$, we are on the increasing side. Set $\texttt{low} \gets \texttt{mid}+1 = 4$.
$\textit{Iteration 3:}$
\[
\texttt{low}=4,\quad \texttt{high}=5,\quad \texttt{mid}=4
\]
\[
\begin{array}{c|ccccccccc}
i & 1 & 2 & 3 & \color{blue}{4} & \color{red}{5} & 6 & 7 & 8 & 9 \\ \hline
A[i] & 2 & 5 & 8 & \color{blue}{12} & \color{red}{15} &13 &10 & 6 & 3
\end{array}
\]
Since $A[4] = 12 < 15 = A[5]$, set $\texttt{low} \gets 5$.
Now $\texttt{low} = \texttt{high} = 5$. The peak is at index $p = 5$.
This phase uses at most $\lceil \log_2 n \rceil$ comparisons.
$\textbf{Phase 2: Search in sorted subarrays}$
Split the array at the peak:
- Increasing part: $A[1..5] = [2,5,8,12,15]$
- Decreasing part: $A[6..9] = [13,10,6,3]$
First, perform standard binary search on $A[1..5]$ for $x=10$ → not found.
Next, search in the decreasing segment $A[6..9]$. Use a binary search adapted for decreasing order:
Initialize $\texttt{low}=6$, $\texttt{high}=9$.
$\textit{Search step:}$
\[
\texttt{mid} = \left\lfloor \frac{6+9}{2} \right\rfloor = 7
\]
\[
\begin{array}{c|ccccccccc}
i & 1 & 2 & 3 & 4 & 5 & 6 & \color{green}{7} & 8 & 9 \\ \hline
A[i] & 2 & 5 & 8 &12 &15 &13 & \color{green}{10} & 6 & 3
\end{array}
\]
$A[7] = 10 = x$ → key found.
In the worst case (e.g., key absent), this phase requires at most $\lceil \log_2 n \rceil$ comparisons per half, so at most $2\lceil \log_2 n \rceil$ total.
$\textbf{Total Complexity}$
- Peak finding: $\leq \lceil \log_2 n \rceil$ comparisons.
- Searching two halves: $\leq 2\lceil \log_2 n \rceil$ comparisons.
Thus, total comparisons $\leq 3\lceil \log_2 n \rceil = O(\log n)$.
Moreover, any comparison-based search among $n$ distinct elements requires $\Omega(\log n)$ comparisons (decision-tree lower bound). Since the increasing half alone contains $\geq n/2$ sorted elements, this bound applies.
Therefore, the worst-case number of comparisons is tightly bounded as:
\[
\boxed{\Theta(\log n)}
\]
Hence, the correct choice is D. $\Theta(\log n)$.