Question: # 1 . ( Chapter 3 ) Consider the following pseudocode for calculating a b , where a and b are positive integers: Input: positive
#Chapter Consider the following pseudocode for calculating where a and b are
positive integers:
Input: positive integers a and b
Output: ab
If b then
return a
else
c:acdota
ans: FastPowerclfloorbrfloor
if bmathrm is odd then
return a ans
else
return ans
Assume for this problem that each multiplication and division can be performed in constant
time. What is the asymptotic running time of this algorithm, as a function of b Please show
how the result is obtained.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
