I understand that why bubble sort is O(n^2).
However in many explanations I see something like this:
(n-1) + (n-2) + (n-3) + ..... + 3 + 2 + 1
Sum = n(n-1)/2
How do you calcuate Sum from this part:
(n-1) + (n-2) + (n-3) + ..... + 3 + 2 + 1
Can anyone help?