Algorithm Analysis -
i have algorithm following pseudocode:
r(n) if(n = 1) return 1 else return(r(n-1) + 2 * n + 1)
i need setup recurrence relation number of multiplications carried out algorithm , solve it.
is following right?
r(1) = 0 r(n) = r(n-1) + n^2
you performing 1 multiplication per step. therefore, relation be:
r(n) = r(n-1) + 1
Comments
Post a Comment