As you know, there are two cases, $n$ odd and $n$ even. It is possible to treat them together, but things are clearer if we treat them separately.
(i) $n$ odd: Let $n=2m-1$. For the largest number, we put $1$ in all the odd numbered places and $0$ elsewhere. (We could call them the even numbered places, and that's probably what I would prefer, but then we have to call the rightmost place the $0$-th place.) Working from right to left, the number we get is
$$1+2^2+2^4+\cdots+2^{2m-2}.$$
It is better to write this as
$$1+4+4^2+\cdots+4^{m-1}.$$
This is a geometric series with first term $1$ and common ratio $4$. The sum is equal to
$$\frac{4^m-1}{4-1}.$$
We could write the sum as
$$\sum_{i=0}^{m-1} 2^{2i}.$$
That does not particularly help: some people are very comfortable with summation notation, others are less comfortable. But in any case we have to find the sum of a geometric series.
(ii) $n$ even: Let $n=2m$. Then the largest number is obtained again by putting a $1$ in the rightmost place, then a $0$, then a $1$, and so on.
The sum is then again
$$1+2^2+2^4+\cdots +2^{2m-2},$$
so we are finding the same sum as before, and get the same answer of
$$\frac{4^m-1}{4-1}.$$
The analysis for the smallest number goes along similar lines.
Remark: It is all too easy to get the index wrong by $1$. So it is quite useful to test the correctness of the indexing by checking with small concrete values of $n$.