What is a reference location?


There are several answers here that talk about reference location, but do not explain what it is.

Where is it applied?

And why is it so important for data structures and algorithms?

asked by anonymous 04.01.2019 / 12:52

1 answer


Reference locale is a concept coming from computer architecture, as the computer's memory is finite there are some algorithms that aim to make memory access faster. The main idea is that there are memories that are faster than others, for For example, it is much faster to access content in RAM than on disk.

This concept also extends to other commercial software, imagine that you have a part of your data that is very accessed, and others that are not so much, and that all of them are in the database, every time you read or write this data, you will need to read and write to the database, this will involve I / O operations and are time-consuming. Ideally, the data that is most accessed would be in the RAM memory of the software, hence the concept of cache.

You can have multiple levels of cache, either the cache in RAM that will be the fastest, or a cache in a database appropriate for this, as is the case with REDIS.

When we talk about algorithms or data structures the same concept is applied, for example, imagine that you need to calculate the Fibronacci sequence of a certain number, and use a recursive algorithm to do this, you can use two approaches, first is that you will always calculate the number and the second is that you will cache the last 200 calculated numbers.

In the first option you spend less memory but spend more processing, the second you spend more memory, in contrast over time your software will be able to calculate the number faster.

04.01.2019 / 13:59