Question: def power ( base , exp ) : if exp = = 0 : return 1 else: return base * power ( base , exp

def power(base, exp):
if exp ==0:
return 1
else:
return base * power(base, exp -1)
def betterPower1(base, exp):
if exp ==0:
return 1
if exp %2==0:
return betterPower1(base, exp //2)* betterPower1(base, exp //2)
else:
return 1* betterPower1(base, exp //2)* betterPower1(base, exp //2)
Which of the following is true about the space complexity of betterPower1?
Question 28 options:
O(1)
O(log(n))
None of the other selections are correct
O(n)
O(n2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!