Question: 4. (18 points) In class, we discussed the Russian Peasant Multiplication (RPM) algorithm. The pseudo- code implementation of this algorithm is: procedure RPM(m: real number;n:

4. (18 points) In class, we discussed the Russian Peasant Multiplication (RPM) algorithm. The pseudo- code implementation of this algorithm is: procedure RPM(m: real number;n: positive integer) 1, total :=0 3, b:= n . while b>1 5, if (b mod 2-1) then total := total + a b:= b div 2 8. return total a (a) Trace (i.e. walk through) an example of the operation of this algorithm when m-714 and n = 64. Note: for full credit, Include enough work to trace the execution of the algorithm on these inputs. Clearly label the output of the algorithm in your answer.) (b) Convert m = 714 and n = 64 to binary notation. Note: include the calculations you use in support of your answer. You need not write an explanation of the conversion for this question. (c) Multiply m = 714 and n = 64 using the usual school algorithm for long multiplication (but in base 2 instead of decimal) Note: include the calculations you use in support of your answer. (d) Convert your answer from part (c) back to decimal, and compare to part (a) Note: include the calculations you use in support of your answer. You need not write an explanation of the conversion for this question. (e) Explain how the steps in parts (a) and parts (c) correspond to one another For full credit, the erplanation must use grammatically correct, complete sentences but may be short. Make specific reference to RPM (either its English-language description from class or the pseudocode above) and to the usual-school-algorithm for long multiplication. (f) Trace the RPM algorithm but now with m-64 and n = 714, Discuss the difference between this computation and part (a). Generalize your observation to come up with a general principle for choosing which number to pick as m and which number to pick as n when you want to combine the product of two positive integers z and y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
