Which of the following is the correct TRIPLE representation of the given below…
Which of the following is the correct TRIPLE representation of the given below assignment statement.
B[i] = b+A[i][j]
Attempted by 47 students.
Show answer & explanation
Triple representation of array A[i] is :

Assumptions:
Row-major layout, element size = 1 (or implicit), number of columns in A = COLS.
Triple format: (op, arg1, arg2). Result of each triple is referred to by its triple number.
Triple representation (one correct expansion):
(*, i, COLS) // t1 = i * COLS
(+, 1, j) // t2 = t1 + j (index within A)
([], A, 2) // t3 = A[t2] (load A[i][j])
(+, 3, b) // t4 = t3 + b (compute b + A[i][j])
([], B, i) // t5 = &B[i] or B[i] (location/value depending on model)
(:=, 4, 5) // store t4 into B[i] (i.e., B[i] := t4)
Loading lesson…