Array Basics and Operations MCQs: 12 Solved Questions with Explanations

Attempt 12 published array MCQs, then check concise explanations for indexing, address arithmetic, search, shifting costs, and rotation.

KnowledgeGate Team

Exam prep & CS education

25 Oct 20267 min read

Array indexing, address arithmetic, and element shifting are the rules that decide most array MCQs. Zero-based positions and byte offsets matter in representation questions, while search, insertion, deletion, and rotation require an explicit trace. Attempt each question before opening its explanation, and write down every intermediate value. Use Data Structures Basics and Types MCQs for the broader classification, access, and operation-matching foundation. The array-specific layer is address calculation, in-place updates, shifting cost, and rotation proofs.

Start with array representation and the base address

C-style arrays start at index 0, and the base address is the address of the first element.

Q1. Array type and starting index

RSSB 2023

An ________ is a homogenous structure and starts with ________ index number.

  • (a) Strings, one

  • (b) Dictionary, zero

  • (c) Array, zero

  • (d) Array, one

Answer: (c) Array, zero. An array holds elements of one declared type. Under the zero-based convention used here, positions begin at index 0. In [8, 13, 21], the mapping is 8 to index 0, 13 to index 1, and 21 to index 2. Other languages can use a different indexing convention.

Q2. Meaning of the base address

CoCubes 2024

What is the base address of an array?

  • (a) Address of the entire array

  • (b) Address of the first element of the array

  • (c) Address of the last element of the array

  • (d) Address of the middle element of the array

Answer: (b) Address of the first element of the array. If arr[0] begins at byte address 1000, then 1000 is the base address. The address of a later element is derived from this starting point, its index, and the width of each element. This definition makes direct address calculation possible without scanning any earlier elements.

Declare arrays, count inclusive indices, and calculate storage

Keep three quantities separate: the declared element count, the valid index range, and the total storage in bytes.

Q3. Declare five integers

Hexaware 2024 and CoCubes 2024

How do you declare an array of integers containing 5 elements?

  • (a) int array[5];

  • (b) int array;

  • (c) array int[5];

  • (d) int array();

Answer: (a) int array[5]; Read the declaration from left to right: int is the element type, array is the name, and [5] reserves five elements. With zero-based C indexing, their valid indices are 0, 1, 2, 3, 4. Index 5 lies outside this array. No sixth slot is reserved.

Q4. Length from the first and last indices

DSSSB 2021

What is the length of an array when its first index is denoted by i and last index is denoted by j?

  • (a) length of an array = i + j

  • (b) length of an array = j - i

  • (c) length of an array = j - i + 1

  • (d) length of an array = j - i - 1

Answer: (c) length of an array = j - i + 1. Let i = 3 and j = 7. The indices are 3, 4, 5, 6, 7, which gives 7 - 3 + 1 = 5 elements. The expression j - i counts the four gaps between these indices, not the five included positions. The plus one includes both endpoints in the count.

Q5. Convert element count to bytes

Capgemini 2025

Assuming int is of 4bytes, what is the size of int arr[15];?

  • (a) 15

  • (b) 19

  • (c) 11

  • (d) 60

Answer: (d) 60. Under the question's assumption, the calculation is 15 elements x 4 bytes per element = 60 bytes. The logical length is still 15 elements, while the storage requirement is 60 bytes. Treat the four-byte width as local to this question, not as a universal rule elsewhere.

If declaration or storage was unclear, review array declaration and initialisation before continuing.

Use address arithmetic to explain constant-time access

For zero-based indexing, use address(arr[k]) = base + k x element_size. The formula links contiguous storage to direct access.

Q6. Difference between two float addresses

Accenture 2023

Consider an array of float. Calculate the difference between the address of the 1st and 4th element, assuming float occupies 4 bytes of memory.

  • (a) 16

  • (b) 4

  • (c) 12

  • (d) 8

Answer: (c) 12. The fourth element is three element-widths after the first, so the difference is (4 - 1) x 4 = 12 bytes. As a direct check, if the first element begins at address 2000, the fourth begins at 2012, again giving a 12-byte difference. The offsets are consistent.

Q7. Access cost when the index is known

CoCubes 2023

What is the time complexity for accessing an element in an array if the index is known?

  • (a) O(1)

  • (b) O(n)

  • (c) O(n log n)

  • (d) O(n^2)

Answer: (a) O(1). With base 1000, four-byte elements, and index 6, the address is 1000 + 6 x 4 = 1024. This calculation takes the same fixed number of steps whether the array contains 10 elements or 10,000. Therefore, access by a known index is constant time in both cases.

Trace an in-place pass and derive sequential-search comparisons

For an in-place update, track the full array after every iteration. For average search cost, average the comparisons over every possible successful position.

Q8. Update neighbours in place

Accenture 2024

What will be the output of the following pseudo code for arr[] = 1, 2, 3, 4, 5 ?

Code
initialize i, n
initialize an array of size n
accept the values for the array
for i = 0 to n - 2
    arr[i] = arr[i] + arr[i+1]
end for
print the array elements
  • (a) 3 5 7 9 5

  • (b) 3 5 7 9 11

  • (c) 3 5 9 15 20

  • (d) error

Answer: (a) 3 5 7 9 5. The states are i=0: [3,2,3,4,5]; i=1: [3,5,3,4,5]; i=2: [3,5,7,4,5]; and i=3: [3,5,7,9,5]. At each step the right neighbour is still unchanged, while index 4 is never assigned. The final array matches option (a).

Q9. Average successful sequential-search cost

GATE 1996

The average number of key comparisons done in a successful sequential search in a list of length n is

  • (a) log n

  • (b) (n-1)/2

  • (c) n/2

  • (d) (n+1)/2

Answer: (d) (n+1)/2. If the target is equally likely at positions 1 through n, the average is (1 + 2 + ... + n) / n = [n(n+1)/2] / n = (n+1)/2. For n=5, the direct average is 15/5 = 3, which matches (5+1)/2 = 3. This confirms the general formula directly.

Separate search cost from shifting cost in sorted arrays

Binary search can locate a position in O(log n), but insertion or deletion can still take O(n) because array elements must move.

Q10. Worst-case insertion into a sorted array

CoCubes 2024

What is the worst-case time complexity of inserting an element into a sorted array?

  • (a) O(n log n)

  • (b) O(log n)

  • (c) O(n)

  • (d) O(n²)

Answer: (c) O(n). To insert 5 at the front of [10,20,30,40,50], shift 50, 40, 30, 20, and 10 one slot right, then write 5. Even if the insertion point is already known or found in O(log n), up to n moves dominate the cost.

Q11. Which sorted-array operation is not constant time

Cognizant 2025

Which of the following operations is not O(1) for an array of sorted data. You may assume that array elements are distinct.

  • (a) Find the ith largest element

  • (b) Delete an element

  • (c) Find the ith smallest element

  • (d) All of the above

Answer: (b) Delete an element. In [10,20,30,40,50], the 2nd smallest and 2nd largest values are direct index lookups, 20 and 40, once n is known. Deleting 20 requires shifting 30, 40, and 50 left. Deleting near the front can therefore shift O(n) elements, as shown.

Prove the three-reversal rotation instead of memorising it

Split the array as s = AB, where A contains the first k items. Then trace what each reversal does.

Q12. Rotation through three reversals

GATE 2014

Suppose you are given an array s[1..n] and a procedure reverse(s, i, j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence do, where 1 <= k < n:

Code
reverse(s, 1, k);
reverse(s, k + 1, n);
reverse(s, 1, n);
  • (a) Rotates s left by k positions

  • (b) Leaves s unchanged

  • (c) Reverses all elements of s

  • (d) None of the above

Answer: (a) Rotates s left by k positions. Symbolically, the steps produce A^R B, then A^R B^R, and finally BA. For s=[1,2,3,4,5] and k=2, the states are [2,1,3,4,5], [2,1,5,4,3], and [3,4,5,1,2]. The result is a left rotation by two positions.

Read the result pattern and choose the next practice step

Misses on Q1 to Q7 point to representation, indexing, or address arithmetic. Misses on Q8 to Q11 point to tracing and operation costs. If Q12 caused trouble, write every intermediate array state instead of memorising a rotation label.

For a full exam-oriented sequence, continue with GATE Guidance by Sanchit Sir. For coding-focused practice, use DSA Using Java. You can also browse the wider Coding and DSA category and choose the next weak area deliberately.