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

Tutor

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

A textbook I recently read discussed row major & column major arrays. The book primarily focused on 1 and 2 dimensional arrays but didn't really discuss 3 dimensional arrays. I'm looking for some good examples to help solidify my understanding of addressing an element within a multi-dimensional array...
read more
A textbook I recently read discussed row major & column major arrays. The book primarily focused on 1 and 2 dimensional arrays but didn't really discuss 3 dimensional arrays. I'm looking for some good examples to help solidify my understanding of addressing an element within a multi-dimensional array using row major & column major arrays. 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

using pointer in program
Comments

JAVA Trainer

Address is always remain same for one or n dimensional matrix
Comments

Computer

Using pointer u can calculate the address of matrix but it will be machine architecture dependent
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

Tutor

with the help of pointers you can easily get the work done.
Comments

View 18 more Answers

Related Questions

What is the benefit of using enum to declare a constant?
ENUMS.. Can give numerical values for Sunday, Monday,... Easy to use in coding... Makes the program more readable/ understandable, than using 1,2,3.. Etc.
Sita
0 0
7
In Java programming, what are the differences between the functions of 'int' and 'int []' when working with an array?
INT type of function return type is int where as for int return type is int array.
Kalpana
0 0
5
How can I learn C easily and rapidly?
Practise as much as you can. Skill in programming comes mainly from experience.
Umamahesh
0 0
5
Can the last case of a switch statement skip including the break?
Last case if a switch should be DEFAULT.. Good to have this case always. Executed only when there's no other matching cases found.
Sanjeev
Can stdout be forced to print somewhere other than the screen?
Although the stdout standard stream defaults to the screen, you can force it to print to another device using something called redirection
Vijay
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

Understanding Computer Science Concepts with Images and Videos..
All Computer science concepts relating to programming and software development are only virtual. It cannot be practically shown as a hardware parts of a computer. But for better understanding it should...

Design your own Mouse Driver in C Language
Mouse Driver (msdrv.h) #include #include union REGS i,o; restrictmouseptr(int x1, int y1, int x2, int y2) { i.x.ax=7; i.x.cx=x1; i.x.dx=x2; ...

Storage classes in c
Storage classes determine the scope and life time of a variable. Scope is defined as the region over which the defined variable is accessible. Lifetime is the time during which the value of a variable...

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...

Why we need to learn Programming languages?
Language is medium for communication. If two parties like to communicate or exchange the thoughts they must know a language. Language should be understandable by both the Parties. For example A wants to...

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 >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

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