Question: 2. Consider the following pseudocode for calculating a (where a and b are positive integers) FastPower(a,b) : if b = 1 return a else c:=ata

2. Consider the following pseudocode for calculating a (where a and b are positive integers) FastPower(a,b) : if b = 1 return a else c:=ata ans := FastPower(c)[b/2]) if b is odd return aans else return ans end end Here [b/2] denotes the floor function, that is, the largest integer less than or equal to b/2. Now assuming that you use a calculator that supports multiplication and division (i.e., you can do multiplications and divisions in constant time), what would be the overall asymptotic running time of the above algorithm (as a function of b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
