Figure 6.11 shows translation of multi-dimensional arrays in rowmajor layout, where the address of each element is found through multiplication and addition. On machines with fast memory access but...



Figure 6.11 shows translation of multi-dimensional arrays in rowmajor layout, where the address of each element is found through multiplication and


addition. On machines with fast memory access but slow multiplication, an alternative implementation of multi-dimensional arrays is sometimes used: An array with


dimensions dim0, dim1,..., dimn is implemented as a one-dimensional array of size


dim0 with pointers to dim0 different arrays each of dimension dim1,..., dimn, which


again are implemented in the same way (until the last dimension, which is implemented as a normal one-dimensional array of values). This takes up more room, as


the pointer arrays need to be stored as well as the elements. But array-lookup can


be done using only addition and memory accesses.


a) Assuming pointers and array elements need four bytes each, what is the total


number of bytes required to store an array of dimensions dim0, dim1,..., dimn?


b) Write translation functions for array-access in the style of Fig. 6.11 using this


representation of arrays. Use addition to multiply numbers by 4 for scaling indices by the size of pointers and array elements.



May 26, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here