How can we get this solution by solving this recurrence?
5:45 PM
(
$(2)=1$
$(1)=0$
If n is a power of 2 , then we can write $T(n)$ as:
\[
T(n)=2 T(n / 2)+2
\]
After solving above recursion, we get
\[
T(n)=3 / 2 n-2
\]
Thus, the approach does $3 / 2 n-2$ comparisons if $n$ is a power of 2 . And it does more than $3 / 2 n-2$ comparisons if $n$ is not a power of 2 .
METHOD 3 (Compare in Pairs)
If n is odd then initialize min and max as first element.
If $n$ is even then initialize min and max as minimum and maximum of the first tiwo elements respectively.
For rest of the elements, pick them in pairs and compare their