Question

A matrix A has 3 rows and 4 columns: a11 a12 a13 a14  a21 a22...

A matrix A has 3 rows and 4 columns:

a11 a12 a13 a14 

a21 a22 a23 a24

a31 a32 a33 a34

The 12 entries in the matrix are to be stored in row major form in locations 7609 to 7620 in a computer’s memory. This means that the entires in the first row (reading left to right) are stored first, then entries in the second row, and finally entries in the third row.

  • Which location with a22 be stored in?

  • Write a formula in i and j that gives the integer n so that aij is stored in location 7609 + n.

  • Find formulas in n for r and s so that ars is stored in location 7609 + n.

  • Now generalize! Let M be a matrix with m rows and n columns, and suppose that the entries are stored in the computer’s memory in row major form in locations N,N +1,N +2,...,N +mn−1. Find formulas in k for r and s so that ars is stored in location N + k.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

609 2512 3C13 7614 21 619も A32 as3 a34 1619 720 七フヒ

above image depicts the array. in which the number mentioned above the element is the location where that element is stored in computer's memory in the given question.

now, when we try to find the location of element a22 from the image we can clearly guess it is 7614.

Coming to second part of the question, the formula for finding the address(memory location) of the element aij.

Given location for the first element (a11) is 7609.

and start row index of matrix  is 1

and start column index of matrix  is 1

So, the formula for finding the address of the matrix is

A[i,j] = Base address + [C * (i-1)+(j-1)]

Here, C is the total number of columns in given matrix.

so the formula for the Given question will be

A[i,j]= Base address + [4 * (i-1) + (j-1)]

Solving for a22 -

a[2,2] = 7609 + [4*(2-1) + (2-1)]

a[2,2] = 7609 + [4*1 + (2-1)]

a[2,2] = 7609 + [4 + (2-1)]

a[2,2] = 7609 + [4 + 1]

a[2,2] = 7609 + 5

So, n=5 here.

a[2,2] = 7614.

Now, coming to 3rd part.

the Formula for the ars element of an array will be

ars = Base address + [C * (r-1)+(s-1)]

Where,

C = number of columns in given matrix.

if we need to calculate for n.

n= [C * (r-1)+(s-1)]

where,

C = number of columns in given matrix.

Now, coming to 4th part.

if, we generalize this formula for Matrix M. having m rows and n columns.

for,

A[ars] = [N + n * (r-Lr) + (s-Lc) ]

where,

N= Base address given in question

n = number of columns in Matrix

Lr= Row index of the Mattrix

Lc= Column index of the Matrix.

For calculating k,

k= n * (r-Lr) + (s-Lc)

where,

n = number of columns in Matrix

Lr= Row index of the Mattrix

Lc= Column index of the Matrix.

Add a comment
Know the answer?
Add Answer to:
A matrix A has 3 rows and 4 columns: a11 a12 a13 a14  a21 a22...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT