In the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j,
Posted: Fri Jun 10, 2022 11:58 am
In the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j, k, sum = 0; for (i = 0; i < y; i++) for (j = 0; j < Z; j++) Ok on the outside, i in the middle, j on the inside. Ojon the outside, k in the middle, i on the inside. The order does not matter. Oi on the outside, j in the middle, k on the inside (as is). for (k = 0; k < x; k++) sum += a[k][j];