I am reading this post which explains the algorithm to compute the two maximum numbers in an array.
In the second algorithm, we need to compute the number of comparisons that the algorithm makes.
The formula proceeds as follows: $$ T(2) = 1 $$
$$ \begin{array} \text{T} (n) &= \text{T}\left(\dfrac{n}{2}\right) + \dfrac{n}{2} + 1 \\ &= 1 + \sum_{1}^{\log_2 n-1} \dfrac{n}{2^i} + 1 \end{array} $$
I am already lost. How did we pass from the first recursive formula to the second explicit one?
I wouldn't know where to start.
It comes from iterating the recursive relation backward. Note in that post you cite, they assume $n$ is a power of $2$, i.e. $\log_2 n$ is an integer. Then
$$\begin{align*} T(n)&=1+n/2+T(n/2)\\ &=1+n/2+1+n/4+T(n/4)\\ \vdots\\ &=\left(1+n/2+1+n/4+...+1+n/2^{k}\right)+T(n/2^k)\\ &=T(2^{-k+\log_2n})+\sum_{i=1}^k\left\{1+\frac{n}{2^i}\right\}\\ \end{align*} $$ Choosing $k=-1+\log_2 n$ and using $T(2)=1$ gives the desired result: $$T(n)=1+\sum_{i=1}^{-1+\log_2 n}\left\{1+\frac{n}{2^i}\right\}.\quad (1)$$
You can simplify this further by using the identity for the sum of the first $k$ terms of a geometric series: $$\sum_{i=1}^kr^i=r\frac{1-r^k}{1-r},r\neq 1.$$ Yours is the case where $r=1/2,k=-1+\log_2 n$. Thus, after some algebra, $(1)$ simplifies to
$$T(n)=n-2+\log_2n,\quad (2)$$
as obtained in that post. Of course, one could cover their tracks like a fox and simply prove $(2)$ directly using the recursive relation via induction.