I'm currently working on reducing the summation on the first line. The three lines below show the steps of the reduction according to the instructor. Unfortunately I'm not following the logic. Can someone help explain the algebraic transformations between each line?
$$\sum_{i=0}^{n-2} n-i-1$$
$$=n(n-1)-(n-1)-\sum_{i-0}^{n-2}{i}$$
$$=(n-1)^2-\frac{(n-2)(n-1)}{2}$$
$$=\frac{n(n-1)}{2}$$
We first split the sum:
$$\sum_{i=0}^{n-2}(n-i-1)=\color{#4488dd}{\sum_{i=0}^{n-2}(n-1)}-\color{#cc5500}{\sum_{i=0}^{n-2}i}$$
One can then factor:
$$\sum_{i=0}^{n-2}(n-1)=(n-1)\sum_{i=0}^{n-2}1$$
and
$$\sum_{i=0}^{n-2}1=\underbrace{1+1+1+\dots+1}_{n-1}=n-1$$
And so,
$$\color{#4488dd}{\sum_{i=0}^{n-2}(n-1)=(n-1)(n-1)=n(n-1)-1(n-1)}$$
which is an explanation for the first step. In the next line, you will notice that it reduces down to $(n-1)^2$, which should be fairly obvious.
On the other hand, we have
$$\color{#cc5500}{\sum_{i=0}^{n-2}i=\frac{(n-2)(n-1)}2}$$
This has been heavily proven in many answers, so I'll leave it to you to see how all that works out.
The last step was combining the fractions:
$$\color{#4488dd}{(n-1)^2}-\color{#cc5500}{\frac{(n-2)(n-1)}2}=\color{#4488dd}{\frac{2(n-1)(n-1)}2}-\color{#cc5500}{\frac{(n-2)(n-1)}2}$$
$$=\frac{2(n-1)(n-1)-(n-2)(n-1)}2$$
$$=\frac{(2(n-1)-(n-2))(n-1)}2$$
$$=\frac{n(n-1)}2$$