Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6735193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:58:49+00:00 2026-05-26T10:58:49+00:00

I wanted to ask about spatial and temporal locality . If I am in

  • 0

I wanted to ask about spatial and temporal locality . If I am in a loop with a looping variable say i and I am traversing an array named arr[i], then when I access arr[i] then according to me it should be both temporal and spatial locality as first I would accesss i and find out what i is and then go to that index. I am doing two things here,

  1. Accessing i (Temporal locality).
  2. Accessing the address arr[i] (spatial locality).

Please tell me if I am right with this certain situation.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:58:50+00:00Added an answer on May 26, 2026 at 10:58 am

    Temporal locality: do things happen over a short period of time? If so, they have temporal locality. If not, they do not.

    Spatial locality: are things located close together in space (i.e. memory)? If so, they have spatial locality. If not, they do not.

    Note that when using these terms you need to specify what is local to what; in isolation, they hold little meaning.

    The elements of arr will (assuming the commonly meant implementation of “array”, i.e. data elements allocated in a contiguous block) have spatial locality with respect to each other. You don’t know (at least from anything stated in the question) where i will be located with respect to arr, so you can’t say if these objects exhibit spatial locality with respect to each other or not.

    The statements accessing i and arr[i] happen one after another, so these exhibit temporal locality, assuming the work you do on each array element is cheap; with this assumption, the referencing of different elements of arr by subsequent iterations will also exhibit temporal locality. If, however, for each iteration of the loop you call some function that takes a long time in between accessing i and arr, it will no longer be true that these accesses exhibit temporal locality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to ask about using selector from a variable first I have: function
After reading an article about the subject from O'Reilly , I wanted to ask
I wanted to ask a question about server data. I am new to server
I wanted to ask the SO community about this problem in my project. I
I wanted to ask about the pros cons of my the following OOP style.
I wanted to ask about the following case: char *temp; temp = malloc(10); Since
I was reading this question , I wanted to ask more about the code
I wanted to ask about the best way to write this JQUERY code. I
This isn't really a coding question, but I wanted to ask about what is
I wanted to ask for a clarification about the use of RowFilter and its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.