- N The Following Code What Order Of Loops Exhibits The Best Locality Int A X Y Z Is Declared Earlier Int I J K 1 (32.25 KiB) Viewed 78 times
n the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j, k
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am
n the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j, k
n 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++) for (k = 0; k< X; k++) k on the outside, i in the middle, j on the inside. Oj on the outside, k in the middle, i on the inside. The order does not matter. i on the outside, j in the middle, k on the inside (as is). sum += a[k][j];