Consider the following expression: x[i] = (p + r) * −s[i] + u / w The…
2024
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). Which one of the following options fills in the missing entries correctly?

- A.
(1) [] s i (3) * (0) (2) (6) [] = x i
- B.
(1) [] = s i (3) − (0) (2) (6) = [] x (5)
- C.
(1) [] s i (3) * (0) (2) (6) [] = x (5)
- D.
(1) [] = s i (3) − (0) (2) (6) [] = x i
Attempted by 18 students.
Show answer & explanation
Correct answer: A
The expression is x[i] = (p + r) * -s[i] + u / w. First, p+r is computed in triple (0). To compute -s[i] in triple (2), we need s[i], so triple (1) must be an array access: [] s i.
Next, the product of (p+r) and -s[i] requires multiplying results of triples (0) and (2), so triple (3) is * (0) (2). Finally, the result of the addition in triple (5) must be assigned to x[i], so triple (6) is [] = x i.
A video solution is available for this question — log in and enroll to watch it.