Which of the following is a disadvantage of a fixed-size array?

Options

  • A. It provides O(1) indexed access
  • B. It stores elements contiguously
  • C. Its size cannot be easily changed after allocation
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. Its size cannot be easily changed after allocation

Detailed Explanation

A traditional fixed-size array has a predetermined capacity, which can make resizing difficult. If more space is required, a larger array may need to be allocated and existing elements copied into it. This can involve O(n) work. On the other hand, fixed-size arrays provide useful advantages such as O(1) indexed access, contiguous memory storage, and good cache locality. Dynamic arrays, such as vectors or ArrayLists, address some resizing limitations while retaining efficient indexed access.