Probably a stupid question but I don't get it right now. I have an algorithm with an input n. It needs n + (n-1) + (n-2) + ... + 1 steps to finish. Is it possible to give a runtime estimation in Big-O notation?
2026-05-16 09:26:57.1778923617
Determine run-time of an algorithm
47 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
Indeed, it is. Since we have $$n+(n-1)+(n-2)+\cdots+1=\frac{n(n+1)}2,$$ then you should be able to show rather readily that the runtime will be $\mathcal{O}(n^2)$.