Which of the following is an advantage of using arrays?
2024
Which of the following is an advantage of using arrays?
- A.
Constant time insertion and deletion
- B.
Ability to store elements of different data types
- C.
Random access to elements using an index
- D.
More than one of the above
- E.
None of the above
Attempted by 1486 students.
Show answer & explanation
Correct answer: C
Step 1: Arrays allow random access to elements using an index, which means any element can be accessed directly in O(1) time using the formula: address = base_address + index * size_of_element. This is a key advantage of arrays. Step 2: Insertion and deletion in arrays are not constant time operations because elements need to be shifted to maintain contiguous memory. This makes Option A incorrect. Step 3: Arrays can only store elements of the same data type. They cannot store different data types in a single array. This makes Option B incorrect. Step 4: Since only Option C is correct, Option D (more than one) and Option E (none) are incorrect.