Question

Multidimensional arrays can be stored in row major order, as in C++, or in column major...

Multidimensional arrays can be stored in row major order, as in C++, or in column major order, as in Fortran. Develop the access functions for both of these arrangements for three-dimensional arrays. Please explain step my step.

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

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

1st column major:

assume you have an array dimensioned [m,n,o] where m=3, n=5,o=2. and you want to find elemt [i,j,k] where i=2,j=2,k=1

the 30 elements are stored as followes array is store asfollows

   0   3   6  9  12               15   18   21   24  27

   1   4   7 10 13                16  19   22   25   28

   2   5   8 11 14                17   20  23   26   29

to find element [2,2,1]   assuming C++ arraynumbering where everything starts with 0 (Fortran starts at 1so theformula would be slightly different) since k=1 you are looking foran element in 2nd plane row 2 col 2 or element # 23

k * (m*n)+(i*m)+j                       element [2,2,1] is in the 2nd plane ∴there is kcomplete m*n elements before it

1 *(3*5)+(2*3)+2                        sinceit's in column 2 there are icomplete columns of m elements beforeit and it

15 + 6+2                                     is the j element in that column thatyou are interested in

23

row major :

assume you have an array dimensioned [m,n,o] where m=3, n=5,o=2. and you want to find elemt [i,j,k] where i=2,j=2,k=1

the 30 elements are stored as followes array is store asfollows

0    1   2    3   4                          15   16   17   18  19

5   6   7   8   9                          20   21   22   23  24  

10 11 12 13 14                         25   26   27 28   29

to find element [2,2,1]   assuming C++ arraynumbering where everything starts with 0 (Fortran starts at 1so theformula would be slightly different) since k=1 you are looking foran element in 2nd plane row 2 col 2 or element # 27

k * (m*n)+(j*n)+i                       element [2,2,1] is in the 2nd plane ∴there is kcomplete m*n elements before it

1 *(3*5)+(2*5)+2                        sinceit's in column 2 there are jcomplete rows of n elementsbefore it and it

15 +10+2                                     is the i element in that rowthat you are interested in

   27

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Multidimensional arrays can be stored in row major order, as in C++, or in column major...
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
  • Develop have the (3. 15pts) Multidimensional arrays can be stored in row major order, as in...

    Develop have the (3. 15pts) Multidimensional arrays can be stored in row major order, as in C++. the access function for the row-major arrangement of three-dimensional arrays that following form: A[1b1. .ub1, 1b2. .ub2, 1b3. u and upper bounds for the respective dimensions of the array. Define the access function that a ub3], where lb and ubs represent the lower compiler needs to implement to compute the address of Al[i.j.K]. Address(ADJ.K]

  • Three dimensional arrays can be stored in row major order, as in C++. Develop the access...

    Three dimensional arrays can be stored in row major order, as in C++. Develop the access function for row major arrangement for three-dimensional arrays. Assume the lower boundaries of the three dimensions are min(1), min(2) and min(3) respectively. Also assume the size of the three dimensions are size(1), size(2) and size(3) respectively. Assume the size of each element is one(1) to simplify the problem. The access function is to find the location of element a(i, j, k), i.e. location(a[i,j,k]) please...

  • Which of the following languages uses column major order? C Java Fortran C++ Which language supports...

    Which of the following languages uses column major order? C Java Fortran C++ Which language supports both rectangular and jagged arrays? C C# C++ Java

  • Hello, Suppose a homogeneous array with 8 rows and 6 columns is stored in column major...

    Hello, Suppose a homogeneous array with 8 rows and 6 columns is stored in column major order starting at address 20 (base ten). If each entry in the array requires only one memory cell, what is the address of the entry in the third row and fourth column? What if each entry requires two memory cells? What is the meaning of address 20 base ten? how I can drwa the array? Thanks,

  • C++ Write a program to calculate the sum of two matrices that are stored inside two-dimensional...

    C++ Write a program to calculate the sum of two matrices that are stored inside two-dimensional arrays. Your program should include three functions: one for getting input data, one for calculating the sum of matrices, and one for printing the result. a) Function inputMatrix: This Function prompts the user to enter the data and stores data inside two-dimensional array. b) Function addMatrices: This function calculatesthe sum result of two matrices. c) Function printMatrix: This function prints the matrix to screen....

  • 6. In C#, an array can have up to 32 dimensions, though arrays with more than...

    6. In C#, an array can have up to 32 dimensions, though arrays with more than three dimensions are very rare. True/False 7. An array is a collection of elements with the same data type that are directly accessed via an integer index. True/False 8. A linear list is? A. A sequential access collection that stores its elements in sequential order. B. A non-sequential access collection that stores its elements in non-sequential order. C. A random collection of elements. D....

  • **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Metho...

    **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Methods Loops and Conditionals Description The goal of this assignment is for you to produce a simple procedurally generated terrain map out of ASCII character symbols. This will be done through simple probability distributions and arrays Use the following Guideline s: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) Keep identifiers to a reasonably short length. User upper case for constants....

  • Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names,...

    Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names, and read in course names from an input file. Then do the output to show each course name that was read in. See Chapter 8 section on "C-Strings", and the section "Arrays of Strings and C-strings", which gives an example related to this lab. Declare the array for course names as a 2-D char array: char courseNames[10] [ 50]; -each row will be a...

  • C LANGUAGE!!! The program uses both files and two dimensional arrays. The Problem Statement Business is...

    C LANGUAGE!!! The program uses both files and two dimensional arrays. The Problem Statement Business is going well for your friend, who is selling discounts to area clubs and restaurants, which means that business is going well for you! Both of you have decided that you'll advertise on memory mall, which is roughly arranged as a rectangle. There's not enough time before a football game to hand flyers to everyone arranged on the mall. Therefore, you will only be able...

  • Game Of life 1. Change the size of the arrays: const int MAX_ROW = 40; const...

    Game Of life 1. Change the size of the arrays: const int MAX_ROW = 40; const int MAX_COL = 80; ***Make sure that only global variables you have in your program are Max_ROW and MAX_COL. Move any global variables you declared to a function or functions. ***Make sure to update setNextGenArray(). Use the variable names, not 40 or 80. ***For testing, I will be changing the array size. Your program should work by only modifying the array size. 2. Use...

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