In the following code, what order of loops exhibits the best locality? // int a[X] [Y][Z] is declared earlier int i, j,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
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,

Post 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 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, 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];
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply