As a hint, here's what the recurrence looks like:
T(1) = 1
T(n) = T(n - 1) + O(n)
This holds because there's always one recursive call made (on an input of size n - 1
), and each individual call does O(n) work.
If you rewrite this as
T(1) ≤ 1
T(n) ≤ T(n - 1) + kn
You can start iterating. As a hint, the final result should be O(n2); I'll leave the details to you.
Hope this helps!