Data Structures

Arrays Store Pointers

Lesson

We've been slightly lying about Arrays, at least in Python. We've been drawing Arrays like this:

But Arrays don't actually store data inside of them like the picture shows. Arrays really store the memory address of where you go to find the data, called a "pointer".

Here's a correct picture of the Array:

This is a 100% accurate picture now. Now let's clean this image up a little. Programmers don't care about the exact memory address of their data. So we can re-draw the picture without the xxx or yyy, and with just a line indicating each pointer:

This is the official picture of the Array. It shows you that you can start at the Array and step along any of the pointers 0, 1, 2. Nodes are places in memory, and arrows are pointers.

Just to give you an idea, here's what a complicated Array looks like:

This picture doesn't only work on Arrays - we'll use the same kind of picture to build all the other Data Structures you need to know about.

Mark as Completed:
Submits:
test
Test your code to get an output here!