✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Consider the following algorithm for calculating x^n:
def fast_power(x, n):
if n == 0:
return 1
elif n % 2 == 0:
p = fast_power(x, n/
2)
return p * p
else:
p = fast_power(x, (n
-1)/2)
return x * p * p
What is the time complexity of this function?
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!