@Abhrajyoti00 regarding your first line, I think it will beT ← xT ← T * x
@Alekhyo Banerjee Why? It is not mentioned in the question that “arithmetic operations have to be done after storing them somewhere”?
They just asked min no. of arithmetic operations reqd using 1 temp variable. So why should I store $x$ first then do $x^2$? We do like this if they ask : “min register reqd. or if it’s explicitly mentioned that operations can only be performed in integer”
In the above 8 steps of evaluation, the total number of arithmetic operations required are 7 [4 Multiplications, 3 Additions] So answer is 7 arithmetic operations.
x5+4x3+6x+5 = x3(x2+4)+6x+5 x3 -> 3 multiply operations (also gives x2) So, Totally we need 3 + 1 multiplications and 3 additions = 7 operations
P(X) = X5+4X3+6X+5
RHS
X(X4+4X2+6)+5
X(((X2)2+2.2.X2+22)+2)+5
X((X2+2)2+2)+5
Now:
T=X*X
T=T+2
T=T*T
T=T*X
T=T+5
Therefore - (* operator used) =3, (+ operator used) = 3 Total=6
@toxicdesire
It is not possible.
because, I thought like this,can we do one register value multiplied with same register value and stored in same register. Is it possible?
Where selected ans done it?
64.3k questions
77.9k answers
244k comments
80.0k users