0 votes 0 votes Given a 3D array A[2:8,-4:1,6:10] stored in a row major order, if the base address is 200 and size of an element is 4 byte, what is the address of A[5][-2][8]? I AM GETTING ANSWER 616 ANSWER IS 608 ?????? AM I WRONG Deepanshu asked Sep 4, 2018 Deepanshu 1.0k views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments MiNiPanda commented Sep 4, 2018 reply Follow Share @Deepanshu https://gateoverflow.in/195348/multidimensional-aaray I didn't go through the answer in your link properly but there is only one way to find it I believe..maybe the explanation seemed clearer to you.. You can check this link.. I tried to give an idea of how it looks.. 1 votes 1 votes Deepanshu commented Sep 4, 2018 reply Follow Share @MiNiPanda nice method..... IS IT SAME FOR BOTH ROW MAJOR AND COLUMN MAJOR ORDER?? 1 votes 1 votes MiNiPanda commented Sep 4, 2018 reply Follow Share No.. it's a bit different like the 2D one 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes I am also getting 608 A[x][y][z] = A[8-2+1][1-(-4)+1][10-6+1]. So A[7][6][5] is our 3-D array. if we go for row major order we consider A[planes][row][columns] we need to know the address of A[5][-2][8] which is A[3][2][2] so we need to cross 3 planes means (6*5 elements in one plane) 90 element after that we need to cross 2 rows (= 10 elements) and 2 column element so the total element we need to cross is (3*6*5)+(5*2)+2 =102 so the address of A[3][2][2] will be = 200+(102*4) = 608 lakshaysaini2013 answered Sep 4, 2018 lakshaysaini2013 comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments Shaik Masthan commented Sep 4, 2018 reply Follow Share @lakshaysaini2013 no need to call me sir. 0 votes 0 votes lakshaysaini2013 commented Sep 4, 2018 reply Follow Share https://en.wikipedia.org/wiki/Row-_and_column-major_order#Address_calculation_in_general let take A[M][N][P] ( note that all indices are starts with 0 ), and required element A[i][j][k] i got the row major order but for column major order using the above given concept i got k*M*N+j*M+i 0 votes 0 votes Shaik Masthan commented Sep 4, 2018 reply Follow Share i am not getting, how they calculated... i consider, Column Major Order as let take A[3][4][5] 000 010 020 030 100 110 120 130 200 210 220 230 001 011 021 031 101 111 121 131 201 211 221 231 002 012 022 032 102 112 122 132 202 212 222 232 003 013 023 033 103 113 123 133 203 213 223 233 004 014 024 034 104 114 124 134 204 214 224 234 if this order is right, then My formula should be right. 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes I think it will help you Shubham Aggarwal answered Sep 4, 2018 Shubham Aggarwal comment Share Follow See all 4 Comments See all 4 4 Comments reply Shubham Aggarwal commented Sep 4, 2018 reply Follow Share check it whrever you going to wrong and correct your mistake. 0 votes 0 votes Deepanshu commented Sep 4, 2018 reply Follow Share @Shubham Aggarwal bro ur answer is correct but i never use this method so little confused 0 votes 0 votes Shubham Aggarwal commented Sep 4, 2018 reply Follow Share ok but this is genral approach i think you should follow this for more accurate answer anyway every question have lot of solution do whichever you like most. 0 votes 0 votes Pranay Binju commented Nov 30, 2018 reply Follow Share Can anyone explain me what does this notation mean?? A[2:8,-4:1,6:10] 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes yes 608 is the right answer. Shubham Aggarwal answered Sep 4, 2018 Shubham Aggarwal comment Share Follow See all 0 reply Please log in or register to add a comment.