Jump to content

Row Major Algorithm


braso

Recommended Posts

Hi guys. I need some help on constructing an algorithm. The question is:

 

Derive an algorithm to store the elements of a table with size n by n in a computer memory using row major. Obtain the elements of the table by:

 

1. Row 1 Column 1 has the value 1; obtained by (1*1)

 

2. Row 2 Column 6 = 12 (2*6)

 

3. Row m Column n = mn (m*n)

 

 

All help will be gladly accepted and appreciated. Thanx!

Link to comment
Share on other sites

umm, that doesn't quite make sense.

if row m column n = n*m then

row 3 column 4 = 12

and row 2 column 6 = 12

and row 1 column 12 = 12

do you see the problem?

 

i believe the standard algorithm is something like the following:

linear value = row*total columns +column.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.