Codele / Data structures
Arrays and memory
Computer memory is a long street of numbered lockers. An array keeps its things in neighbouring lockers, so the computer can jump straight to any one.
- Memory is a street of numbered lockers. Every locker has an address.
- An array keeps its items in neighbouring lockers, in order.
- The address of position i is the start address plus i. That is why reading any position takes one jump.
- Making room at the front means moving every item one place along, one at a time. A long array makes that slow.
- Adding at the end of an array, into a spare locker, moves nothing.
Loading the playable lesson…