Reputation: 3
Question: When a CPU can perform a multiplication in 12 nanoseconds (ns), an addition in 1 ns, and a subtraction in 1.5 ns, which of the following is the minimum CPU time, in nanoseconds, for the calculation of “a×a – b×b ” ?
Answer: 14.5
Upvotes: 0
Views: 193
Reputation: 17836
I believe it optimizes the equation to (a-b)*(a+b) so it's subtraction + addition + multiplication = 12 + 1 + 1.5 = 14.5.
Though my math isn't the best around so if I'm wrong just comment and don't downvote so I can delete :D
Upvotes: 2