Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you are given integers a, b, c, and d, and you must computethe two quant

ID: 3743396 • Letter: S

Question

 Suppose you are given integers a, b, c, and d, and you must computethe two quantities: x = ab+bc+ad-cc and y = ab+cc+cd
 As written, the equations suggest doing seven multiplications, though clearlyif cc is computed and stored in an intermediate variable, then only six multiplications are needed.  This could be expressed algorithmically as:
 temp1 = c*c x = a*b + b*c + a*d - temp1 y = a*b + temp1 + c*d
 which clearly illustrates how to compute the result with six 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 six or seven multiplications suggested above; it's OK to do a few extra assignments, additions, and/or subtractions.) Hint: try to make clever use of the distributive law.

Explanation / Answer

Hey,

Below is the answer to your question

Algorithm

Given, x=ab+bc+ad-cc=(a+c)(b+d)-c(c+d)

y=ab+cc+cd=ab+cc+cd=ab+c(c+d)

Hence by following the above method, we can complete the computation by having to use only three multiplication.

Kindly revert for any queries

Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote