Questions: Array Data Structure: Representation and Operations

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A lookup table stores 1 million integer entries. A program reads entries by index billions of times per second but almost never inserts or deletes. Why are arrays the ideal data structure for this use case?

AArrays keep elements sorted, making binary search faster
BArrays support O(1) random access via address arithmetic and exploit cache locality, making reads extremely fast regardless of array size
CArrays have O(1) insertion at any position, minimizing the rare write overhead
DArrays use less memory per element than any other data structure
Question 2 Multiple Choice

You insert a new element at index 0 of an array containing 10,000 elements. How many elements must be moved, and why?

A1 — only the inserted element is placed
BAbout 5,000 on average — half the array, since indices below and above 0 exist
C10,000 — every existing element must shift one position to the right to make room
D0 — arrays store a pointer to the new element, so no shifting is needed
Question 3 True / False

Appending to the end of a Python list (dynamic array) usually takes O(n) time because the array may need to be resized.

TTrue
FFalse
Question 4 True / False

Array traversal (iterating over all elements in order) is often faster in practice than linked-list traversal, even though both are O(n) in Big-O notation.

TTrue
FFalse
Question 5 Short Answer

Why does contiguous memory layout make array random access O(1) and insertion O(n)? Explain how the same property causes both.

Think about your answer, then reveal below.