proof that (N–1) + (N–2) + (N–3) + ... + 1= N*(N–1)/2
I got this formula from a data structure book in the bubble sort algorithm.
(N-1) + (N-2) +...+ 2 + 1 is a sum of N-1 items. Now reorder the items so, that after the first comes the last, then the second, then the second to last, i.e.(N-1) + 1 + (N-2...
snowcodes.hashnode.dev2 min read