UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

how to calculate address of n dimensional matrix

Asked by Last Modified  

Follow 3
Answer

Please enter your answer

Computer Expert

An n dimensional matrix can be of any dimension. Adding a dimension is adding one more index number (to access the element). In 1-D array you the elements are linearly arranged and can be addressed as a, a, .. . in 2-D array elements are logically in the form of matrix having row and column index and...
read more
An n dimensional matrix can be of any dimension. Adding a dimension is adding one more index number (to access the element). In 1-D array you the elements are linearly arranged and can be addressed as a[0], a[1], .. . in 2-D array elements are logically in the form of matrix having row and column index and can be represented as a[0][0], a[0][1] etc. and they are stored row wise in the memory, because the memory is linear. Now a 3-D array is nothing but a logical structure which can be accessed by 3 index numbers. If the array is of size 3 in all the dimensions(int a[3][3][3] then it is stored in the memory in the following order a[0][0][0], a[0][0][1], a[0][0][2], a[0][1][0], a[0][1][1], a[0][1][2], a[0][2][0], a[0][2][1], a[0][2][2], a[1][0][0], a[1][0][1] and so on. Now to find the address of any element of the array based on the given index number and given dimension size, given element size(data type size) and given base address: Suppose the array is of n-dimension having the size of each dimension as S1,S2,S3. . .. Sn And the element size is ES, Base Address is BA And the index number of the element to find the address is given as i1, i2, i3, . . . .in Then the formula will be: Address of A[i1][ i2][ i3]. . . .[ in] = BA + ES*[ i1*( S2* S3* S4 *. . ..* Sn) + i2*( S3* S4* S5 *.. .. * Sn) + .. . . .. + in-2*( Sn-1*Sn) + in-1*Sn + in ] Example-1: An int array A[100][50] is stored at the address 1000. Find the address of A[40][25]. Solution: BA=1000, ES=2, S1=100, S2=50, i1=40, i2=25 Address of A[40][25]=1000+2*[40*50 + 25]=1450 Example-2: An int array A[50][40][30] is stored at the address 1000. Find the address of A[40][20][10]. Solution: BA=1000, ES=2, S1=50, S2=40, S3=30, i1=40, i2=20, i3=10 Address of A[40][20][10]=1000+2*[40*40*30 + 20*30 + 10]=98220 read less
Comments

Professional Tutor with 15 years of experience.

Array of an element of an array say “A” is calculated using the following formula: Address of A = B + W * ( I -- LB ) Where, B = Base address W = Storage Size of one element stored in the array (in byte) I = Subscript of element whose address is to be found LB = Lower limit / Lower Bound of...
read more
Array of an element of an array say “A[ I ]” is calculated using the following formula: Address of A [ I ] = B + W * ( I – LB ) Where, B = Base address W = Storage Size of one element stored in the array (in byte) I = Subscript of element whose address is to be found LB = Lower limit / Lower Bound of subscript, if not specified assume 0 (zero) Example: Given the base address of an array B[1300…..1900] as 1020 and size of each element is 2 bytes in the memory. Find the address of B[1700]. Solution: The given values are: B = 1020, LB = 1300, W = 2, I = 1700 Address of A [ I ] = B + W * ( I – LB ) = 1020 + 2 * (1700 – 1300) = 1020 + 2 * 400 = 1020 + 800 = 1820 [Ans] read less
Comments

While storing the elements of a 2-D array in memory, these are allocated contiguous memory locations. Therefore, a 2-D array must be linearized so as to enable their storage. There are two alternatives to achieve linearization: Row-Major and Column-Major. two-dimensional-array-memory-address-calculation row-major-column-major-memory-address-calculation Address...
read more
While storing the elements of a 2-D array in memory, these are allocated contiguous memory locations. Therefore, a 2-D array must be linearized so as to enable their storage. There are two alternatives to achieve linearization: Row-Major and Column-Major. two-dimensional-array-memory-address-calculation row-major-column-major-memory-address-calculation Address of an element of any array say “A[ I ][ J ]” is calculated in two forms as given: (1) Row Major System (2) Column Major System Row Major System: The address of a location in Row Major System is calculated using the following formula: Address of A [ I ][ J ] = B + W * [ N * ( I – Lr ) + ( J – Lc ) ] Column Major System: The address of a location in Column Major System is calculated using the following formula: Address of A [ I ][ J ] Column Major Wise = B + W * [( I – Lr ) + M * ( J – Lc )] Where, B = Base address I = Row subscript of element whose address is to be found J = Column subscript of element whose address is to be found W = Storage Size of one element stored in the array (in byte) Lr = Lower limit of row/start row index of matrix, if not given assume 0 (zero) Lc = Lower limit of column/start column index of matrix, if not given assume 0 (zero) M = Number of row of the given matrix N = Number of column of the given matrix read less
Comments

M.Tech (IT)-Pursuing B.E(IT)-Mumbai CCNA,CCNP Functional Testing

Absolutely, academic books do not have multidimensional arrays explained in depth. We are familiar with mostly 2X2 or 3X3 i.e 2 dimensional Arrays. lets say int rupendra ; means that 10 specifies the total number of items in a particular row, so there are 5 rows AND 5 columns too. I think its sufficient...
read more
Absolutely, academic books do not have multidimensional arrays explained in depth. We are familiar with mostly 2X2 or 3X3 i.e 2 dimensional Arrays. lets say int rupendra [5][5][10]; means that 10 specifies the total number of items in a particular row, so there are 5 rows AND 5 columns too. I think its sufficient for now. Cant explained everything here. read less
Comments

Array of an element of an array say “A” is calculated using the following formula: Address of A = B + W * ( I -- LB ) Where, B = Base address W = Storage Size of one element stored in the array (in byte) I = Subscript of element whose address is to be found LB = Lower limit / Lower Bound of...
read more
Array of an element of an array say “A[ I ]” is calculated using the following formula: Address of A [ I ] = B + W * ( I – LB ) Where, B = Base address W = Storage Size of one element stored in the array (in byte) I = Subscript of element whose address is to be found LB = Lower limit / Lower Bound of subscript, if not specified assume 0 (zero) read less
Comments

Given the base address of an array B as 1020 and size of each element is 2 bytes in the memory. Find the address of B. Solution: The given values are: B = 1020, LB = 1300, W = 2, I = 1700 Address of A = B + W * ( I -- LB ) = 1020 + 2 * (1700 -- 1300) = 1020 + 2 * 400 = 1020 + 800 = 1820...
read more
Given the base address of an array B[1300…..1900] as 1020 and size of each element is 2 bytes in the memory. Find the address of B[1700]. Solution: The given values are: B = 1020, LB = 1300, W = 2, I = 1700 Address of A [ I ] = B + W * ( I – LB ) = 1020 + 2 * (1700 – 1300) = 1020 + 2 * 400 = 1020 + 800 = 1820 [Ans] read less
Comments

MCA

Address of A = B + W * ( I -- LB ) Where, B = Base address W = Storage Size of one element stored in the array (in byte) I = Subscript of element whose address is to be found LB = Lower limit / Lower Bound of subscript, if not specified assume 0 (zero)
Comments

using pointer in program
Comments

Tutor

The limit value in the for loop should be "<= n"
Comments

Creative Minds Trainer

Row Wise: The address of a location in Row Major System is calculated using the following formula: Address of A = B + W * Column Wise: The address of a location in Column Major System is calculated using the following formula: Address of A Column Major Wise = B + W * Where, B...
read more
Row Wise: The address of a location in Row Major System is calculated using the following formula: Address of A [ I ][ J ] = B + W * [ N * ( I – Lr ) + ( J – Lc ) ] Column Wise: The address of a location in Column Major System is calculated using the following formula: Address of A [ I ][ J ] Column Major Wise = B + W * [( I – Lr ) + M * ( J – Lc )] Where, B = Base address I = Row subscript of element whose address is to be found J = Column subscript of element whose address is to be found W = Storage Size of one element stored in the array (in byte) Lr = Lower limit of row/start row index of matrix, if not given assume 0 (zero) Lc = Lower limit of column/start column index of matrix, if not given assume 0 (zero) M = Number of row of the given matrix N = Number of column of the given matrix read less
Comments

View 18 more Answers

Related Questions

What does the modulus operator do?
Modulus operator '%' gives the remainder of any expression. For example : r=10%3; // r is 1 , because if you divide 10 by 3 then the remainder is 1
Sumit
When is a "switch" statement better than multiple "if" statements?
switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type. For instance, rather than the code if (x == 1) printf(“x...
Shalu
What is a stream?
Stream means flow... ofstream This data type represents the output file stream and is used to create files and to write information to files. ifstream This data type represents the input file stream and is used to read information from files
Nilam
Is the C language required to learn Java?
No, learning C is not a strict requirement for learning Java. Java and C are distinct programming languages with different syntax, features, and purposes. While having a background in C can provide a solid...
Akhilesh
0 0
7
How can I make my C programming basics strong?
Practise more programs on each and every topic of C.
Mohit
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

C++ Program-Working with constant using #define preprocessor
//Header Files #include#include // using #define preprocessor for defining a constant#define len 10#define br 5#define rad 3#define NEWLINE '\n' //Main function void main(){ int area_r; float area_c; //Function...
S

Some Tricky Questions in C
Can you write two functions in which one executes before main function and other executes after the main function? #pragma startup #pragma exit Where, priority is optional integer value.For user priority...

Tress And Its Traversal
Depth First Traversals:(a) Inorder (Left, Root, Right) : 4 2 5 1 3(b) Preorder (Root, Left, Right) : 1 2 4 5 3(c) Postorder (Left, Right, Root) : 4 5 2 3 1 Trees are one of the data structures like...

Efficient Learning Strategies
Type your notes after class Write your notes onto flashcards - Scrabble -Make posters Review flashcards while walking, at gym, etc. Dog-ear pages in the reading where you can find...

Necessity of Theory and Practical in Computer Science.
Upon studying a subject both theory and practical are important. Usually many schools concentrate more on theory and the marks not on the practical. Other and opposite kind of people prefer practical...

Recommended Articles

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more