Last reviewed
Correct answer: D. Array elements are stored in contiguous memory, allowing direct computation of an element's location
Explanation
Contiguity turns a lookup into arithmetic. Every element occupies the same number of bytes, so the address of index i is the base address plus i times the element size. One multiply, one add, one fetch. The cost is identical whether the array holds ten items or ten million, which is what constant time means. The C++ standard states the layout guarantee plainly: an array is a contiguous container.
This is also why an array beats a linked list on lookup and loses on insertion. Reaching the thousandth node of a list means following a thousand pointers; reaching index 999 of an array is a single calculation. NIST defines the random access model as one in which arithmetic operations are allowed to compute the address of a memory register, and that is the mechanism.
D describes the linked-list traversal that arrays exist to avoid. B and C are not descriptions of arrays at all. NIST calls an array an assemblage of items randomly accessible by integers, the index; random there means any index costs the same, not that the ordering is scrambled between accesses. Layout is fixed at allocation.
Sources
“An assemblage of items that are randomly accessible by integers, the index.”
“In this model, arithmetic operations are allowed to compute the address of a memory register.”
“An array is a contiguous container”
Practise 3 questions on this topic
Take Arrays & Strings — Timed Test (3 questions) — scored instantly, explanation for every question, no login.