Page 1 of 1

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
by correctanswer
In The Following Code What Order Of Loops Exhibits The Best Locality Int A X Y Z Is Declared Earlier Int I J 1
In The Following Code What Order Of Loops Exhibits The Best Locality Int A X Y Z Is Declared Earlier Int I J 1 (36.57 KiB) Viewed 94 times
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];