OA. free
Free
Qualcomm Embedded Systems & Hardware Data Structures & Algorithms Medium

The elements of an array are stored successively in memory cells because:

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

The elements of an array are stored successively in memory cells because:

Choose one option.
Show answer & explanation
Answer: D. by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated.

Arrays are stored contiguously in memory to enable efficient address calculation using the base address and index. Given the base address and element size, the address of any element can be computed as: address = base_address + (index × element_size). This design choice provides optimal performance and minimal storage overhead. Option D correctly identifies the core reason, while C overstates it as an architectural constraint, B combines two separate concerns awkwardly, and A is factually incorrect.

Step-by-step Derivation:
Address calculation for contiguous arrays:

  1. Store only the base address (first element location).
  2. For element at index i with size s: address[i] = base_address + (i × s).
  3. This enables O(1) random access without storing individual pointers.
  4. While memory is linear, arrays can theoretically be scattered, but sequential storage optimizes CPU cache locality and arithmetic simplicity.
  5. Option D captures the practical design rationale; Option C incorrectly frames this as a hard architectural limitation rather than a design choice.