- 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 93 times
In the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j,
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am
In the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j,
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];