Question: 1 . ( 1 0 points ) Let y and z be n - bit integers, where n is a power of 3 . Consider

1.(10 points) Let y and z be n-bit integers, where n is a power of 3. Consider the following
divide-and-conquer algorithm to compute the product yz.
Divide y into three n
3-bit pieces, a, b, and c; thus y = a22n/3+ b2n/3+ c, where the powers of
2 denote appropriate bit-shifting. Similarly, divide z into pieces d, e, and f . Now compute yz
recursively as:
yz = ad24n/3+(ae + bd)2n +(af + be + cd)22n/3+(bf + ce)2n/3+ cf.
You may ignore the issue of carries throughout this problem.
(a) Write down the recurrence, T (n), for the worst-case running time of this algorithm. Analyze
T (n) using the Little Master Theorem and determine the running time.
With a view towards improving the running time in part (a), consider the following approach,
where we first compute certain intermediate products (r1,..., r6) recursively and use these along
with additions and bit-shifts to compute yz.
r1=?, r2=(a + b)(d + e), r3= be, r4=?, r5= cf, r6=?, and yz =?.
(b) Fill in the missing information above for r1, r4, and r6 and show how to compute yz. Try to
use as few multiplications as you can to compute r1, r4, and r6.
(c) Write down the recurrence, T (n), for the worst-case running time of this algorithm. Analyze
T (n) using the Little Master Theorem and determine the running time. How does it compare with
the running time of the algorithm we designed in class, where we divided the input integers into
halves?

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!