954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

finding the weight of an array element

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?

th_3
Newbie Poster
3 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 
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[I][J] = B + W ( c ( I – Lr) + ( J – Lc) )

A = name of array
I = row subscript
J = column subscript
B = Base address
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

th_3
Newbie Poster
3 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

"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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 
"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

th_3
Newbie Poster
3 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You