A lesson from the Computer Memory module of the bootcamp. About a 14 minute read.
A bit is a physical switch with two positions, a byte is eight of them, and memory is one enormous row of bytes, each with a number. That is the entire model, and every data structure in this bootcamp is built on it. An array is a run of bytes, a pointer is one of those numbers, and a type is nothing but an agreement about how to read what is there.
From your program's point of view, memory is one enormous array of BYTES, and every byte has a number called its ADDRESS, starting at 0. The processor does two things with it: read the byte at an address, and write the byte at an address. Everything else is built on those two. An int is four bytes in a row. An array of a thousand ints is four thousand bytes in a row, which is why nums[i] can be found at base + 4i with no searching, the math the Arrays lesson called random access. A string is a run of bytes plus an encoding. An object is a block of bytes whose fields sit at fixed distances from its start. If you keep one picture from this module, keep this one: a long row of numbered boxes, with eight bits in each.
The rest of this lesson continues with 6 further sections. See the full curriculum.
Browse all 576 practice puzzles