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

Is it necessary to learn the C language and also C++ before joining an engineering college?
it is not necessary to learn C and C++, but if you want to make your are career in computer then learn C & C++ because these are basic computer language.
J.k.kavyadharshini
In Java programming, what are the differences between the functions of 'int' and 'int []' when working with an array?
The may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable but But int a keeps type information together and is more verbose so I prefer it.
Kalpana
0 0
5
How and where do I start learning C programming?
Goals Fundamental concepts of C programming language. Write your first C program. Understand different keywords & Data types in C. Understand Variables & Scope of Variables. Learn Enumeration or Enum...
Krishna
0 0
5
I’ve been learning C language for 3 weeks but it’s becoming more difficult. As a result, I’m becoming lazy. What should I do to motivate myself?
Learn algorithm or flowchart first. Once you start C, try to relate with real time example. Example: When learn printf() , think about a a bill where you customer information is printed. Similarly when...
Akhilesh
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 Are IT Industries Performance Metrics?
1. Outstanding Expectation: Eligible to get Promotion easily and good salary hike. Always preferrable to go abroad. 2. Exceed Expectation: Can get Promotion as per schedule of company with good salary...

Bit wise operators in C
Bit Wise Operators Bit Wise operators are manipulates of individual bits with in a word of memory. The bit wise operators can be divided in to three general category. One’s Complement...


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

Basic Concepts of Web Designing
An introduction to domain names, web servers, and website hosting 1)What is the web? In a nutshell, the web is a whole bunch of interconnected computers talking to one another. The computers (on the...

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