Which of the following exhibit spatial locality: 1. Repetition control flow 2. Binary search on an array of integers 3. Accessing the elements of a row in a 2D array that is heap allocated as an array of arrays

Respuesta :

Answer:

1. Repetition control flow

3. Accessing the elements of a row in a 2D array that is heap allocated as an array of arrays

Explanation:

1. Elements in 1D memory are stored in contiguous memory location thus it follows spatial locality. ( RIGHT OPTION)

2. Binary search in an array does not follow spatial locality because the elements in an array with the binary search are not accessed in a contiguous manner but in a non-contiguous manner. HENCE IT IS NOT RIGHT OPTION

3. Sequencing control also follows spatial locality ( RIGHT OPTION)