python 3.x - How to calucate the number of steps in interative exponent -
def exp2(a,b): if b == 1: return else: return a*exp2(a,b-1) i want calucate number of program. accodring textbook, attached how calucate steps.
t(b) = 3 + t(b-1) = 3 + 3 + t(b-2) = 3k + t(b-k)
if it's done b-k=1 k=b-1
t(b) = 3(b-1) + 2 = 3b -1
i can't understand why first number 3. how can number 3 in beginning?
step 1: b == 1
step 2: a*exp2
step 3: b-1
the first round 3, can t(b) = 3 + t(b-1).
Comments
Post a Comment