Prerequisite – Locality of Reference
1. Spatial Locality :
Spatial Locality means that all those instructions which are stored nearby to the recently executed instruction have high chances of execution. It refers to the use of data elements(instructions) which are relatively close in storage locations.
2. Temporal Locality :
Temporal Locality means that a instruction which is recently executed have high chances of execution again. So the instruction is kept in cache memory such that it can be fetched easily and takes no time in searching for the same instruction.
Difference between Spatial Locality and Temporal Locality :
|S.No.||Spatial Locality||Temporal Locality|
|1.||In Spatial Locality, nearby instructions to recently executed instruction are likely to be executed soon.||In Temporal Locality, a recently executed instruction is likely to be executed again very soon.|
|2.||It refers to the tendency of execution which involve a number of memory locations .||It refers to the tendency of execution where memory location that have been used recently have a access.|
|3.||It is also known as locality in space.||It is also known as locality in time.|
|4.||It only refers to data item which are closed together in memory.||It repeatedly refers to same data in short time span.|
|5.||Each time new data comes into execution.||Each time same useful data comes into execution.|
Data elements accessed in array (where each time different (or just next) element is being accessing ).
Data elements accessed in loops (where same data elements are accessed multiple times).
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Spatial and Temporal Data Mining
- Computer Organization | Locality and Cache friendly code
- Locality of Reference and Cache Operation in Cache Memory
- Difference between CD and DVD
- Difference between DDL and TCL
- Difference Between DVD-R and DVD+R
- Difference between OOP and POP
- Difference between DFD and ERD
- Difference between Hue and Pig
- Difference Between DAS and SAN
- Difference between GSM and LTE
- Difference between T-SQL and PL-SQL
- Difference between H.323 and SIP
- Difference between AIX and iOS
- Difference between IBM DB2 and MS SQL
- Difference between C++ and Go
- Difference Between Blu-Ray and DVD
- Difference between C and C++
- Difference between AIX and OS/2
- Difference between TCP and RTP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.