The function is this:
function max-element
if n = 1
return A[1]
else
x = max-element(A[2...n])
if A[1] > x
return A[1]
else
return x
So to create to recurrence relation i've done this, which i'm unsure of...
T(1) = 2, because the function will only execute the first if and return if n=1
T(n) = T(n-1) + c, and c = 5 when n>1
T(n-1) = T(n-2) + c
T(n-2) = T(n-3) + c
generalized, T(n) = T(n-k) + 5k ... this is where I think i'm going off?
And in the worst-case, k=n-1..... T(n)=T(1)+5n-5=5n-3
Then T(n) = Theta(n).
Any help?