Question: Algorithms- Suppose you are given integers a, b, c, and d, and you must compute the two quantities x = ab-cc+bd and y = bb-cc+ad.

Algorithms- Suppose you are given integers a, b, c, and d, and you must compute the two quantities x = ab-cc+bd and y = bb-cc+ad. As written, the equations suggest doing six multiplications, though clearly if cc is computed and stored in an intermediate variable, then only five multiplications are needed. This could be expressed algorithmically as: temp1 = c*c x = a*b - temp1 + b*d y = b*b - temp1 + a*d which clearly illustrates how to compute the result with five multiplications. That still is not very efficient, though. By cleverly computing more complex intermediate quantities, show how to compute x AS WELL AS y by using only a total of three multiplications (instead of the five or six multiplications suggested above; it's OK to do a few extra assignments, additions, and/or subtractions.) Clearly state your algorithmic steps, naming your intermediate quantities, and showing the order in which you compute them [like the sample pseudocode using temp1 shown above]. 

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