Can some explain me the row & column wise representation of a 2 dimensional array in stack? My teacher told that if we have following matrix:
a00 a01 a02
a10 a11 a12
a20 a21 a22
Column wise representation: Row Wise representation:
a00 a00
a10 a01
a20 a02
a01 a10
a11 a11
a21 a12
a02 a20
a12 a21
a22 a22
Whereas i only know about the representation of multidimensional array in memory: a00 then a01 then a02 then a10 and so on(there increasing order of addresses)
I raised this question in class what is the difference b/w stack representation & memory representation of multidimensional arrays. She said we are doing 2-D array here not pointer. What kind of answer is that. Please explain me this.
She also told some formulae to calculate the address of any element of 2-D array of row representation and column representation in stack. I didn't understand it.
Location(A[j,k]) = Base_address(A) + W(M(k-1)+(j-1))