Multidimensional array

Hello,
Is a 100x100x100 array much much more complicated and calculation intensive than a say, 5x5x5 array, even though we will only have only few, same number of used elements in each ? For example assume each array will have only 2-3 used elements at any given time, even the 100x100 array.

How about if most array elements were used ?
Last edited on
Is a 100x100x100 array much much more complicated and calculation intensive than a say, 5x5x5 array

No. The address arithmetic is exactly the same. Only the multipliers are different.

For example assume each array will have only 2-3 used elements at any given time, even the 100x100 array. How about if most array elements were used ?

Makes no difference to the address arithmetic required.
Depends. It is likely that the 100x100x100 will not fit in your cpu cache / page, and will have problems with memory access, worse if you are not careful how you iterate over it.

If most of the elements are used, its going to cost a lot more time to process.
5x5x5 is 125 items. 100x100x100 is 1000000 items. this is significant.

If you use 10 items from each, you won't notice the difference, even with the page fault/cache hits.

Depending on what you are doing, even 1000000 items can be trivial on today's machines. But if you are doing something that takes a lot of work per item, it will slow to a crawl in a hurry. For example a good sorting algorithm would be done with that before your finger left the keyboard telling it to go, while computing an optimal path graph algorithm might still be running after the colony on mars has been established.



Topic archived. No new replies allowed.