
Correct : c
Explanation:
To determine the missing elements, let's break down how three-address code triples represent array accesses and assignments. A triple consists of three fields: op (operator), arg1, and arg2. When referencing the result of a previous operation, the row number enclosed in parenthesesβlike (0)βis used.
1. Analyze Triple (1): Array Indexing of s[i]
β’ The sub-expression is s[i].
β’ In three-address code triples, an array access/r-value lookup uses the array base address and index. The operator is represented as =[].
β’ Therefore, row (1) evaluates s[i]:
(1) =[] s i
β’ This eliminates options (b) and (d), which specify []= (used for array assignment/l-value, not lookup).
2. Analyze Triple (2): Unary Minus
β’ Looking at the table, row (2) computes uminus (1), which represents -s[i]. This confirms our deduction for row (1) is correct.
3. Analyze Triple (3): Multiplication
β’ The expression requires multiplying (p+r) by -s[i].
β’ Row (0) computed + p r (which is p+r).
β’ Row (2) computed -s[i].
β’ Therefore, row (3) must perform the multiplication of row (0) and row (2):
(3) * (0) (2)
4. Analyze Triples (4) and (5): Addition with u/w
β’ Row (4) computes / u w (which is u/w).
β’ Row (5) adds row (3) and row (4) together: + (3) (4). This represents the entire right-hand side of our assignment equation.
5. Analyze Triple (6): Target Array Location x[i]
β’ The value calculated in row (5) needs to be stored into the left-hand side array position x[i].
β’ Before a value can be assigned to an array element, we define its l-value location using the array base address and index with the element assignment operator []=.
β’ Therefore, row (6) targets the x[i] element:
(6) []= x i
6. Analyze Triple (7): Assignment
β’ Row (7) shows = (6) (5), which copies the computed right-hand side expression from row (5) into the array destination specified in row (6).
7. Conclusion:
Matching our findings (1) =[] s i, (3) * (0) (2), and (6) []= x i directly corresponds to choice (c).
Similar Questions
Total Unique Visitors