I have a method:
int Tree (int n) {
if (n <= 0) return 0;
if (n == 1) return 1;
return ((n*n) + Tree (n-3));
}
I'm trying to find the recurrence relation that captures the running time T(n) for the method 'Tree', so far I've got T(n) = T(n-3) + O(1), then I will need to express the running time as a series of terms, where each term denotes the number of operations at a distinct level of the recursion tree:
I have T(n) = T(n-3) + O(1) then T(n-1) = T(n-4) + O(1) then T(n-2) = T(n-5) + O(1) ... But Im unsure if this is right