3D and Multidimensional Array MCQs: 10 Solved Questions with Explanations
Solve ten multidimensional-array questions with lower-bound normalisation, address formulas, array transformations, and careful step-by-step traces.
KnowledgeGate Team
Exam prep & CS education

Most multidimensional-array errors come from inclusive bounds, the fastest-varying index, or element-size multiplication. Start by converting every inclusive bound into a dimension length, then decide which index varies fastest before multiplying by element width. Row-major and column-major addresses, element counts, rotation traces, Young tableaux, and right-to-left scans each reduce to an explicit sequence of steps.
1. The four facts to write before solving a multidimensional-array MCQ
Write four facts before calculating:
An inclusive range from
LtoUhas lengthD = U - L + 1.Total elements equal the product of all dimension lengths.
In row-major order, the last index varies fastest.
In column-major order, the first index varies fastest.
Array Basics MCQs in C owns the broader declarations, output traces, and basic array algorithms. The calculations here use three-dimensional bounds and separate row-major from column-major strides. For A[L1:U1, L2:U2, L3:U3], use lengths D1, D2, and D3.
Row-major offset:
(i-L1)D2D3 + (j-L2)D3 + (k-L3)Column-major offset:
(i-L1) + D1(j-L2) + D1D2(k-L3)Address:
base + offset x element size
An offset counts elements. The final multiplication converts that count into a word or byte displacement.
Check a zero-based 2 x 3 x 4 array: A[1][2][3] has row-major offset 1 x 12 + 2 x 4 + 3 = 23, the final slot among 24 elements.
2. Row-major address questions: normalise every lower bound
Q1. Row-major address in A[2:8, -4:1, 6:10]
DSSSB 2021, Computer Science, PGT
Consider an array A[2 : 8, -4 : 1, 6 : 10]. Base address of array A is 400 and size of each element is 2 words per memory cell. What is the address of A[5, -1, 8] in row-major form?
Options: (a) 628; (b) 614; (c) 630; (d) 626.
Answer: (b) 614. D2 = 1 - (-4) + 1 = 6 and D3 = 10 - 6 + 1 = 5. Normalised indices are 5-2 = 3, -1-(-4) = 3, and 8-6 = 2.
Offset = 3(6)(5) + 3(5) + 2 = 90 + 15 + 2 = 107 elements.
Address = 400 + 107 x 2 = 614.
Using raw 8 instead of 8-6 produces option 626. Practise it in the 3D and multi-dim arrays PYQ module.
![Row-major address of A[5,-1,8] in A[2:8, -4:1, 6:10]: offset 90 + 15 + 2 = 107, so the address is 400 + 107 x 2 = 614.](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1784664644829_o5ls5o.jpg)
Q2. The same address asked a second time
DSSSB 2021, Computer Science
Consider an array A[2 : 8, -4 : 1, 6 : 10]. Base address of array A is = 400 and size of each element = 2 word per memory cell. What is the address of A[5, -1, 8] in row major form?
Options: (a) 628; (b) 614; (c) 630; (d) 626.
Answer: (b) 614. In row-major order the repeat arithmetic is unchanged: 400 + 107 x 2 = 614. If the same cell were asked in column-major order, the first index would vary fastest, so the offset would be 3 + 7(3) + 7(6)(2) = 3 + 21 + 84 = 108 and the address would become 400 + 216 = 616. The order named in the question therefore decides the multipliers before you substitute any number. Retry this version too in the arrays PYQ module.
Q3. Reading the row-major formula off a C declaration
TCS 2024
A three dimensional array in 'C' is declared as int A[x][y][z]. Consider that array elements are stored in row major order and indexing begins from 0. Here, the address of an item at the location A[p][q][r] can be computed as follows (where w is the word length of an integer):
(a)
&A[0][0][0] + w(y * z * q + z * p + r)(b)
&A[0][0][0] + w(y * z * p + z*q + r)(c)
&A[0][0][0] + w(x * y * p + z * q+ r)(d)
&A[0][0][0] + w(x * y * q + z * p + r)
Answer: (b). p skips p planes of y x z elements, q skips q rows of z, and r skips individual elements. Thus the offset is p(yz) + qz + r, multiplied by w. With p=q=r=0, it returns the base. Work more formula variants in the placement PYQ module.
3. Count elements first, then count possible arrays
Q4. Counting how many ternary arrays exist
UP Police 2016, Computer Science, Paper 2 - Subject Oriented (Shift II)
Number of different ternary arrays (an array in which each cell can store either 0, 1, or 2 is called ternary array) of order n x n is:
(a) n^3
(b) 3^(n x n)
(c) n^3
(d) 3^n
Answer: (b) 3^(n x n), or 3^(n^2). Each of the n x n cells independently holds 0, 1, or 2, so multiply three by itself n^2 times. For n=2, 3 x 3 x 3 x 3 = 81. Options (a) and (c) print the same expression, so neither can be the intended answer.
Q5. Counting elements in A(1:8, -5:5, -10:5)
Indian Space Research Organization 2013, Computer Science
Let A(1:8, -5:5, -10:5) be a three dimensional array. How many elements are there in the array A?
Options: (a) 1200; (b) 1408; (c) 33; (d) 1050.
Answer: (b) 1408. Lengths are 8-1+1 = 8, 5-(-5)+1 = 11, and 5-(-10)+1 = 16, so 8 x 11 x 16 = 1408. Their sum, 35, is not the array size. Try more sizing questions in the ISRO PYQ module.
4. Trace the three-reversal rotation instead of recalling a slogan
Q6. What three reversals do to an array
GATE 2000, Computer Science
Suppose you are given an array s[1..n] and a procedure reverse(s, i, j), which reverses the elements from positions i through j, both inclusive. What does this sequence do when 1 <= k < n?
reverse(s, 1, k); reverse(s, k + 1, n); reverse(s, 1, n);
Options: (a) Rotates s left by k positions; (b) Leaves s unchanged; (c) Reverses all elements of s; (d) None of the above.
Answer: (a). Trace s = [1,2,3,4,5,6,7], n=7, k=2.
First reversal:
[2,1,3,4,5,6,7]Second reversal:
[2,1,7,6,5,4,3]Final reversal:
[3,4,5,6,7,1,2]
The result is a left rotation by two positions, which is what the three reversals achieve for any k. Trace it again in the GATE guidance PYQ module.
5. Column-major NATs: let the first index vary fastest
Q7. Column-major address in A(1:8, -5:5, -10:5)
Suppose a multidimensional array is declared as A(1..8, -5..5, -10..5). If the base address is 400 and each element occupies 4 words, what is the address of A[3, 3, 3] in column-major order?
Answer: 5240. The question gives 4 words per memory location, so the size factor is W=4. Here D1=8, D2=11, D3=16, and the normalised indices are 2, 8, and 13.
Offset = 2 + 8(8) + 8(11)(13) = 2 + 64 + 1144 = 1210.
Address = 400 + 4(1210) = 5240.
Q8. The same column-major address by the nested form
Suppose a multidimensional array is declared as A(1..8, -5..5, -10..5). If the base address is 400 and each element occupies 4 words, what is the address of A[3, 3, 3] in column-major order?
Answer: 5240. The numbers repeat, so use the nested form of the same column-major offset as a cross-check:
400 + 4(((((3-(-10)) x 11) + (3-(-5))) x 8) + (3-1))
= 400 + 4((13 x 11 + 8) x 8 + 2)
= 400 + 4(1210) = 5240.
Read the units off the question: it counts words per memory location, so keep 5240 in those same units and call it a byte address only when a question says bytes.
6. Two boundary cases: a Young tableau and right-to-left maxima
Q9. Minimum shifts to remove 1 from a Young tableau
GATE 2015, Computer Science, Set 2
A Young tableau is a 2D array of integers increasing from left to right and from top to bottom. Unfilled entries are marked as infinity, so no filled entry can appear to their right or below them. The following Young tableau has unique entries.
1 | 2 | 5 | 14 |
3 | 4 | 6 | 23 |
10 | 12 | 18 | 25 |
31 | infinity | infinity | infinity |
When 1 is removed, move other entries into its place while preserving the Young-tableau order. What is the minimum number of entries, other than 1, that must shift?
Answer: 5. Move the smaller right or lower neighbour into the hole: 2, 4, 6, 18, 25, then infinity. Five finite entries move because each smaller choice preserves increasing rows and columns. Redo the shift path in the GATE guidance PYQ module.

Q10. Counting updates in a right-to-left maximum scan
An array A[1..n] of distinct integers is processed from right to left. A variable max is initialized with the last element. For each A[i], if A[i] > max, max is updated to A[i]. The recorded count k is the number of times max changes during the traversal. Which statements are always true?
(a) The algorithm executes in O(n) time and uses O(1) extra space.
(b) 1 <= k <= n for any input array of size n.
(c) For a strictly decreasing array, k = n.
(d) For a strictly increasing array, k = 1.
Answer under the intended convention: (a), (b), (c), and (d). Count the initial assignment from the last element as the first recorded value. The scan then takes O(n) time and O(1) extra space, with 1 <= k <= n. Scanning [5,4,3,2,1] from the right gives k=5, while [1,2,3,4,5] gives k=1. If k counts only updates after initialisation, then only (a) is always true: the increasing array gives k=0 and the decreasing array gives k=n-1. The time and space claim is independent of that counting convention.
7. Final trap checklist and the next practice step
Before submitting an answer:
Add one when counting an inclusive range.
Subtract each index's own lower bound.
Decide the fastest-varying index before choosing multipliers.
Multiply the element offset by element size exactly once.
Write every intermediate array or grid for trace questions.
Use CS Fundamentals for Exams and Placements to revise the surrounding data-structure sequence after the address formulas and traces are stable.
Use DSA Using Java for structured DSA work and GATE Guidance by Sanchit Sir for GATE-oriented sequencing.
Recompute Q1 and Q7 on a blank page, then retry Q4, Q8, and Q10 without looking at the explanations. The 3D and multidimensional arrays PYQ module supplies the related practice path for questions that do not have individual lesson URLs.
Keep learning

1D and 2D Array Addressing MCQs: 12 Solved Questions
Solve 12 array-address questions step by step, from negative lower bounds and 1D offsets to row-major, column-major, triangular and tri-diagonal storage.

Structure Modification and Pointer Logic MCQs: 10 Solved Linked List Questions
Solve 10 linked-list MCQs by tracing each pointer update. The explanations cover reversal, duplicate removal, deletion, insertion, sentinels, and invalid links.

Binary Tree Properties MCQs: 12 Solved Questions with Explanations
Work through 12 binary tree MCQs from GATE and campus papers, then use the explanations and one worked tree to fix mistakes in shape, degree and recursion.

Stack Basics and Operations MCQs: 12 Solved Questions with Step-by-Step Explanations
Test stack fundamentals through 12 exam MCQs on LIFO, TOP, array bounds, queue transfers and permutations. Complete traces make every state and answer checkable.