2 2 votes "Arrays have better cache locality that can make them better in terms of performance"--- What does it mean by that ? Programming in C array programming-in-c + – Mj_chain 1.9k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 8 8 votes Answer and Explanation According to the concept of Spatial Locality, if the data in location 'n' is accessed, there is a high chance that the data in location 'n+1' will be accessed soon. Therefore, several contiguous memory blocks are loaded onto the machine's cache to speed up the data access. Since arrays are stored in a contiguous manner, they are best suited for this and thereby improving performance. shekhar chauhan answered Jun 28, 2016 • selected Jun 28, 2016 by Mj_chain shekhar chauhan comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote All the elements of array are placed in consecutive memory location, unlike linked list, whose every element is placed at random location. While accessing memory, memory management system always fetch block of words in cache from memory, so in one block fetch, CPU can get many array elements in one block. locality of reference: is a term for the phenomenon in which the same values, or related storage locations, are frequently accessed rameshbabu answered Jun 28, 2016 rameshbabu comment Share Follow 0 reply Please log in or register to add a comment.