Jump to content

Row Major Algorithm

Featured Replies

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!

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.

i believe the standard algorithm is something like the following:

That's not an algorithm anyway. I hate these stupid CS-homework questions from people who are in the wrong place.

Edited by Ben Bowen

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.