Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 30, Problem 1P

a.

Program Plan Intro

To multiply two linear polynomials ax+b and cx+d using only three multiplications.

a.

Expert Solution
Check Mark

Explanation of Solution

Multiply two linear polynomials ax+b and cx+d using only 3 multiplications as follows:

  (a+b)(c+d)=ac+cb+ad+cd

Thus, the product of two polynomials is as follows:

  acx2+((a+b)(c+d)accd)x+cd

b.

Program Plan Intro

To provide two divide-and-conquer algorithms for multiplying two polynomials of degree-bound n in Θ(nlg3) time.

b.

Expert Solution
Check Mark

Explanation of Solution

Method 1(for dividing the input polynomial coefficients into a high half and low half):

Take two polynomials be P1 and P2 such that, P1(x)=j=1n1aj,1xj and P2(x)=j=1n1aj,2xj .

Now, assume that two polynomials are to be multiplied. Then,High half will be Hi(x)=j=n/2n1aj,ixj and Low half will be Li(x)=j=n/2n/21aj,ixj wherei =1,2….and so on.

Since, it is known that Pi(x)=Hi(x)xn/2+Li(x) wherei =1,2…and so on.Therefore, by multiplication of two polynomials following is obtained:

  P1(x)P2(x)=(H1(x)H2(x))xn+(H1(x)+L1(x))(H2(x)+L2(x))

  (H1(x)H2(x)L1(x)L2(x))xn/2+L1(x)L2(x)

Now on using master’s theorem the recurrence for above is calculatedto be as follows:

  T(n)=3T(n/2)+θ(n)

  θ(nlg(n))

Method2(for dividingthe input polynomial coefficients based onif the index is even or odd the procedure):

Assume the odd index beOiand even index be Eisuch that Oi(x)=j=0n/21a2j+1,jxj and Ei(x)=j=0n/21a2j,jxj where i goes from 1,2, 3… and so on.

Then, Pi=xO(x2)+Ei(x2)

Therefore,

  P1(x)P2(x)=x2(O1(x2)O2(x2))+x(O1(x2)+E1(x2))(O2(x2)+E1(x2))(O1(x2)O2(x2)E1(x2)E2(x2))+E1(x2)E2(x2)

Now on using master’s theorem the recurrence for above is calculatedto be as follows:

  T(n)=3T(n/2)+θ(n)

  θ(nlg(n))

c.

Program Plan Intro

To show methodto multiply two n-bit integers in O(nlg3) steps.

c.

Expert Solution
Check Mark

Explanation of Solution

To multiply two n-bit integers in O(nlg3) steps, take two integers P1 and P2 such that

  P1=k=0lg(A1)ak,12k and P2=k=0lg(A2)ak,22k .

The generalization of the polynomial can be given as f1=k=0lg(Ai)ak,ixi .

The two n-bit integers can be taken as P1nP1n1........P1 and P2nP2n1........P2 where 0P1i10 and 0P2i10 . The value P1i and P2i represent the number on every digit i = {1,2,3…n}

  P1n10n1+P1n110n2+.+P1210+P11

  P2n10n1+P2n110n2++P2210+P21

These two algorithms are developed to solve the multiplication problem of polynomialwith run time of O(nlg3) by using divide and conquer. Each operationdeal with either P1or P2, they are of 1bit values.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Consider the following MAXMIN algorithm. How many comparisons does it use? Is it likely to be faster or slower than the divide-and-conquer algorithmin practice? procedure maxmin2(S) comment computes maximum and minimum of S[1..n] in max and min resp. 1. if n is odd then max:=S[n]; min:=S[n] 2. else max:=−∞; min:=∞ 3. for i := 1 to n/2 do 4. if S[2i − 1] ≤ S[2i] 5. then small:=S[2i − 1]; large:=S[2i] 6. else small:=S[2i]; large:=S[2i − 1] 7. if small < min then min:=small 8. if large > max then min:=small
Design a transform-and-conquer algorithm for finding the minimum and the maximum element of n numbers using no more than 3n/2 comparisons. Justify the number of comparisons of your algorithm.
What is the difference between Transform and Conquer & Divide and Conquer?  Justify your answer by providing at one example for each algorithm in solving a problem.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning