Question: 2. (3) a) Use the statement of Algorithm POWERC to count the number of multiplications required by POWERC for the following values of m (i)


2. (3) a) Use the statement of Algorithm POWERC to count the number of multiplications required by POWERC for the following values of m (i) 13, (ii) 21, (iii) 31. In each case also state the num- ber of multiplications required by POWERA. b) Let m = 2 +j, 0 S; 2. But suppose m is not a power of 2. Can we still improve on Algorithm POWERA? Algorithm 1.3 POWERC answers this question Algorithm 1.3 Power Input ,m Im an integer and > 1) Output power (=31 Algorithm POWERC powerk [ mk nincem 1 repeat until 2km (Until k is biggest possible power of 25 m power poter X power k2k endrepeat repeat until km por power X k+1 endrepeat Algorithm POWERC ile doublings as in Power as long as it can and the multiplies wively by until power. We leave the number of multiplications required to a problem (2) Perhaps you see how to improve Algorithm Powen further (20)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
