Before you learn about data structures like arrays, you need to know one simple thing first: where does a computer keep its data? Once you understand how a computer stores and finds information, everything about data structures becomes much easier to follow.
Think about a simple task: adding two numbers.
The part of the computer that does the math is the CPU (the "brain"). Inside it, a small unit called the ALU (Arithmetic Logic Unit) does calculations. So when you ask the computer to do 10 + 6, the ALU happily gives back 16.
But here is the question: where does that 16 go? You will probably want to use it later. The CPU is great at calculating, but it is not built to hold lots of results. It needs a separate place to store the answer and get it back when needed.
That place is computer memory.
Computer memory, also called RAM, is a chip — just like the CPU is a chip. But it has a different job:
A good way to picture it: the CPU is like a person solving a math problem in their head, and memory is the notebook where they jot down intermediate answers so they don't forget them.
Memory is an electronic chip, so it only understands electrical signals: high voltage and low voltage. We write these as:
1 for high (think: switch on)0 for low (think: switch off)This means *every* piece of data must be turned into a string of 0s and 1s before it can be stored. This form is called binary.
10 in binary is 1010.So whether it's a number, a letter, or a picture — to the computer, it's all just 0s and 1s.
When you write a program, you should not have to worry about voltages and chips. That is what a memory model is for: it gives you a simple mental picture of memory so you can think clearly about your data.
Here is the picture to keep in your head:
> Memory is a long row of numbered boxes, starting at box 0 and ending at box n - 1, where n is the total number of boxes.
This single idea covers 99% of what you need to know as a programmer.
Now let's look inside one box.
0 or 1, like a tiny switch that is on or off.So a byte is the basic unit of data, the same way a meter is a basic unit of distance. One box in our picture = one byte = 8 bits.
Storing data is easy, but to *get it back* you need to know exactly which box it's in. So every box needs a unique label.
The simplest label is just the box's position counted from the very first box: 0, 1, 2, 3, and so on. This position number is called the address of the byte.
One important rule:
> The address of a piece of data is the address of the first byte where that data begins.
So if a number is spread across several boxes, you only remember where it *starts*. From there, the computer reads as many boxes as it needs.
Your code does not run directly. First a tool called the compiler turns your code into machine code (raw instructions made of 0s and 1s). Then:
While running, the CPU constantly talks to memory:
This back-and-forth is like a brain: one part breaks down the problem (the CPU), and another part remembers the in-between results (the memory). Notice that memory holds both things at once — the program's instructions *and* the data the program creates or changes.
This simple model — numbered boxes, bytes, and addresses — is the foundation. It explains how basic data types like integers, characters, and floats are stored, and later it will explain how things like pointers and arrays work. Keep this picture in mind, and the rest of data structures will make sense.