Practice 20 Arrays multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: A — O(1)
Arrays provide constant time O(1) access because elements are stored in contiguous memory locations.
Show Answer & Explanation
Correct Answer: B — O(n)
Inserting at beginning requires shifting all elements, making it O(n).
Show Answer & Explanation
Correct Answer: B — n-1
Arrays are 0-indexed, so last element is at index n-1.
Show Answer & Explanation
Correct Answer: B — Quick Sort
Quick Sort has O(n²) worst case (already sorted) but O(n log n) average case.
Show Answer & Explanation
Correct Answer: C — m × n
A 2D array of m rows and n columns has m × n total elements.
Show Answer & Explanation
Correct Answer: B — Sorted array only
Binary search requires the array to be sorted to work correctly.
Show Answer & Explanation
Correct Answer: C — O(log n)
Binary search halves the search space each time, giving O(log n).
Show Answer & Explanation
Correct Answer: B — O(n)
An array of n elements uses O(n) space.
Show Answer & Explanation
Correct Answer: C — Dynamic size
Arrays have fixed size. Dynamic size is not an advantage of static arrays.
Show Answer & Explanation
Correct Answer: C — B + i × S
Address of arr[i] = Base + i × Size of each element.
Show Answer & Explanation
Correct Answer: C — O(n)
Linear search checks each element one by one, taking O(n) in worst case.
Show Answer & Explanation
Correct Answer: B — Sorted
Binary search only works on sorted arrays as it relies on the ordering to eliminate half the elements.
Show Answer & Explanation
Correct Answer: C — O(log n)
Binary search halves the search space each time, giving O(log n) complexity.
Show Answer & Explanation
Correct Answer: B — m × n
A 2D array with m rows and n columns has m × n total elements.
Show Answer & Explanation
Correct Answer: B — Row by row
In row-major order, elements of each row are stored contiguously in memory.
Show Answer & Explanation
Correct Answer: B — Array with mostly zero/default values
A sparse array has most of its elements as zero or default values.
Show Answer & Explanation
Correct Answer: B — O(n)
All remaining n-1 elements must be shifted left, taking O(n) time.
Show Answer & Explanation
Correct Answer: B — Rows can have different sizes
Jagged arrays (arrays of arrays) can have rows of different lengths.
Show Answer & Explanation
Correct Answer: B — Doubling capacity
Most dynamic array implementations double capacity when full for amortized O(1) insertion.
Show Answer & Explanation
Correct Answer: C — O(n)
Must check every element to find minimum, taking O(n) time.