Question: # 1 . ( Chapter 3 ) Consider the following pseudocode for calculating a b , where a and b are positive integers: Input: positive

#1.(Chapter 3) Consider the following pseudocode for calculating ab, where a and b are
positive integers:
Input: positive integers a and b
Output: ab
If b =1 then
return a
else
c:=a\cdota
ans:= FastPower(c,\lfloorb/2\rfloor)
if }b\mathrm{ 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.
# 1 . ( Chapter 3 ) Consider the following

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 Programming Questions!