Given this question below,

Each element of an array arr[10][10] requires ‘W’ bytes of storage. If the address of arr[6][8] is 4580 and the Base address at arr[1][1] is 4000, find the width of ‘W’ of each cell in the array arr[ ][ ], when the array is stored as Column Major Wise.

How does one find the weight of the array?

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by th_3

Read the question again. The word "weight" appears nowhere. The is a math problem and requires you to understand that arrays are contiguous and also how a 2-D array uses the [x][y] pair, starting address, and array size too convert it to an address. presumably there's a formula in your notes. Plug the known values into the formula and solve for the unknown value using algebra.

Read the question again. The word "weight" appears nowhere. The is a math problem and requires you to understand that arrays are contiguous and also how a 2-D array uses the [x][y] pair, starting address, and array size too convert it to an address. presumably there's a formula in your notes. Plug the known values into the formula and solve for the unknown value using algebra.

This is the formula

A [J] = B + W ( c ( I – Lr) + ( J – Lc) )

A = name of array
I = row subscript
J = column subscript
W = Weight of element
c = number of columns ( Max col subscript – Min col subscript ) + 1
Lr = Lowest row subscript
Lc = Lowest column subscript

It is easy to calculate the address using this formula when the value of 'W' is provided. 'W'stands for the weight of an element or the number of bytes based on the data type of the array

"Weight", "Width", whatever. In the problem statement it's called "width", in the formula it's called "Weight". I can only go by what you provided and the question statement refers to it as "width". Take the formula and start plugging in the values given in place of the letters. Eventually you'll end up with nothing but W and that's your answer.

"Weight", "Width", whatever. In the problem statement it's called "width", in the formula it's called "Weight". I can only go by what you provided and the question statement refers to it as "width". Take the formula and start plugging in the values given in place of the letters. Eventually you'll end up with nothing but W and that's your answer.

Thank you