Which of the following highly uses the concept of an array?

2023

Which of the following highly uses the concept of an array?

Answer: C. Spatial localitySpatial locality is the memory-access principle that when one memory address is accessed, addresses physically close to it are highly likely to be accessed…

  1. A.

    Binary search tree

  2. B.

    Scheduling of processes

  3. C.

    Spatial locality

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 2180 students.

Show answer & explanation

Correct answer: C

Spatial locality is the memory-access principle that when one memory address is accessed, addresses physically close to it are highly likely to be accessed soon after. A structure exhibits this property to the extent that it packs its elements into contiguous memory locations, since visiting one element then naturally lands near the next.

  • Binary search tree: each node is allocated wherever the heap has free space and is linked only through left/right child pointers, so traversing it jumps between scattered addresses rather than contiguous ones.

  • Scheduling of processes: the scheduler's defining structure is a queue that orders processes by arrival time or priority; that ordering discipline -- not contiguous memory layout -- is what characterizes scheduling.

  • Spatial locality: an array stores every element at consecutive addresses, so stepping through indices i, i+1, i+2 accesses adjacent memory directly -- the textbook case of this principle.

  • More than one of the above: would require at least two listed items to independently store elements in contiguous memory; only one does.

  • None of the above: would require that no listed item satisfies the contiguous-memory test; one clearly does.

Cross-check: CPU caches fetch a whole cache line -- a contiguous block of memory -- on every miss, so an access pattern is best exploited when the underlying storage is itself laid out contiguously. Among the options here, that is precisely the array's default behaviour: unlike a pointer-linked binary search tree or a queue-based scheduler (neither of which need keep their elements together in memory), an array's very definition guarantees contiguous storage.

Therefore, the concept that highly uses the array is spatial locality.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…