0 votes 0 votes Consider the following code: for (i=0; i <20; i++) for ( j= 0; j< 10; j++) a[i] = a[i]* j ; a. Give one example of the spatial locality in the code. b. Give one example of the temporal locality in the code. focus _GATE asked Jun 7, 2015 focus _GATE 7.2k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes a. a[1] is accessed after a[0] both are near memory locations and hence example of spatial locality. b. a[0] is accessed for j = 0 and for j = 1; same memory location accessed in nearby time and hence example of temporal locality. Arjun answered Jun 7, 2015 Arjun comment Share Follow See all 2 Comments See all 2 2 Comments reply focus _GATE commented Jun 7, 2015 reply Follow Share sir can we consider inner for loop as a temporal locality.... and outer for loop as spacial.........?? 1 votes 1 votes Arjun commented Jun 7, 2015 reply Follow Share yes. 0 votes 0 votes Please log in or register to add a comment.