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

How do I learn C++ from the basics?
First you learn C LANGUAGE
Priyanka
0 0
6
Basics of 'C'language
C is middle level language, using C you can write program which directly interact with the hardware like device driver programming or you can write GUI application. C is very powerful language compare...
Raghavendra
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
How can I develop my C language?
https://vz-3ad30922-ba4.b-cdn.net/c616c4df-8596-4ae7-bb61-c6f1d87e5e4d/play_480p.mp4
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

What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

C Program-Temperature [conversion from farenheit to degree celsius]
//WAP to convert temperture from farenheit into degree celsius //Header files#include<stdio.h>#include<conio.h> //Main functrion void main(){ //Variable declaration of type float float...
S

How do i get best Campus / Off Campus Placement?
Companies are looking for Skilled Freshers. So build your technical skills while doing MCA / BTech / BCA / BSc (IT or CS) into below areas- 1. Strong your programming & debugging skills ...

Variables
Variables in C Language:A variable is a name that may be used to store a data value. Unlike constant, variables are changeable, we can change value of a variable during execution of a program. A programmer...

Be prepared to get trained--init
Before starting the training,students must be mentally prepared for acceptance of new knowledge. Students must attend training with open minded forgetting the position they are working.This will help...
S

Smartnub Softsolutions

0 0
0

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