Given two integers x and n, describe and prove an algorithm that computes xn.
Is there any way to go faster than O(n)?
function power(x, n)
if n is 0
return 1
else if n is odd
temp = power(n / 2)
return x * temp * temp
else
temp = power(n / 2)
return temp * temp
end if
end
time complexity of this algorithm is O(log(n))
Given two integers x and n, describe and prove an algorithm that computes xn. Is there...