I am a novice programmer and I recently started learning Algorithm and DS. I often see in tutorials and books the mention of the term “take the data into memory” like in sorting, Information Retrieval. Although I understand the process of storing data into an array or a HashMap (in case of IR) but I dont really understand what role memory plays in it?
Can anyone guide me through the fundamentals of memory in these kinds of scenarios or suggest me some tutorials for the same?
At a basic level a computer only has two things:
All the pieces of data consist of just 1’s and 0’s.
However, there are a lot of places that these pieces of data can be, which could all be called memory.
ROM (read-only memory: the memory you computer boots from to be able to interact with the motherboard and stuff.)
Hard-Disk (data saved on the hard-disk will not be lost when the computer is turned off. Operating System, personal files, etc.)
RAM (random-access memory: applications can quickly read and write into RAM, but the data goes away when the computer is rebooted. HashTables, Objects, the data your program deals with are stored here.)
Cache (various levels of caches exist. frequently accessed parts of the RAM memory gets copied to cache-memory so an application can access/modify that data faster. Modified data will be moved back to the RAM, and from RAM can be saved to the Hard Disk).
External-Memory (an internet connection or other connection may give you even more places where data can be stored, but accessing that memory takes much longer).
When “Memory” is used in the form “take the data into memory” such as in tutorials or books, they usually mean take data from the hard-disk memory into the RAM memory.
This is because the operations that a computer performs can only be performed on data which is stored in RAM. (although, someone is sure to comment with some exception).