The principle of locality of reference suggests if a reference is made to a memory location, next reference is close to it. So, it is a basic assumption that processors fetch memory locations close to it, to optimize fetch time. Since the array is stored in row-major form AFAIK, elements in the same row are closer to each other and more likely to be in cache together, as compared to elements in different rows.
On Mon, Aug 8, 2011 at 5:12 PM, Prakash D <[email protected]> wrote: > @gaurav: are u sure? > > On Mon, Aug 8, 2011 at 3:40 PM, Amir <[email protected]> wrote: >> >> Both Will take same time..... >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/algogeeks/-/hwcTUmMW_zsJ. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
