I am confused on solving this time complexity problem.
T(n) = T(n-1)
I know in quick-sort worst case T(n) = T(n-1) + T(1) + n
Which evaluates to (n-1) + (n-2) + (n-3) + ... + 1
& this geometric sequence equals O(n^2)
However. I see answers on stackoverflow that say T(n) = T(n-1) + c = O(n)
.
How is this possible when this is also equal to (n-1) + (n-2) + (n-3) + ... + 1
, which equals O(n^2)
Can somebody please explain.