Consider the following expression: \(x[i] = (p + r) * -s[i] + u/w\). The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).
| (0) | + | \(p\) | \(r\) |
| (1) | |||
| (2) | uminus | (1) | |
| (3) | |||
| (4) | / | \(u\) | \(w\) |
| (5) | + | (3) | (4) |
| (6) | |||
| (7) | = | (6) | (5) |
Which one of the following options fills in the missing entries CORRECTLY?
Answer
(A)
Explanation
Triples have no result names: an operand is either a name or the number of an earlier triple.
- (1)
=[] s ireads the element \(s[i]\), the value that (2) negates. The operator[]=stores into an array element and produces no value foruminusto use. - (3)
* (0) (2)multiplies \(p + r\) by \(-s[i]\), which (5) then adds to \(u/w\). The expression contains no subtraction, so the options with – fail here too. - (6)
[]= x imarks the array location \(x[i]\), and (7) assigns the value of (5) to it. Putting (5) inside (6) would lose the index \(i\) and duplicate the work of (7).
Answer: A