Two programmers asked to write the code to evaluate the following expression:
a - b + c/(a-b) + (a-b)2
Pankaj writes the following code statements (Code A):
print (a-b) + c/(a-b) + (a-b)*(a-b)
Mythili writes the following code statements (Code B):
d = (a-b)
print d + c/d + d*d
If the time taken to load a value in a variable, for addition, multiplication or division
between two operands is same, which of the following is true?
Option 1 : Code A uses lesser memory and is slower than Code B
Option 2 : Code A uses lesser memory and is faster than Code B
Option 3 : Code An uses more memory and is faster than Code B
Option 4 : Code A uses more memory and is slower than Code B
Answer: Option 1