To understand how a computer can represents large data structures like our tree diagram, we first need to understand some basic facts about computer memory. Every piece of data that is stored in a computer is kept in a memory cell with a specific address. We can think of these memory cells as being a long row of boxes where each box is labeled with an address. If you have ever used a computer spreadsheet before, you know that spreadsheets also have labeled boxes that can hold data. Computer memory is similar to this with the exception that computer memory is linear. That's why we think of computer memory as being organized in a row rather than a grid like a spreadsheet.

The computer can store many different types of data in its memory. You have already learned about some of the basic types of data the computer uses. These include integers, real numbers, and characters. Once the computer stores data in the memory cells, it can access the data by using the address of the data cells. For example, consider the following instructions for adding two integers together.

 Instructions Computer Memory Store '1' in cell 2003. Store '5' in cell 2004. Add cells 2003 and 2004 and store the result in cell 2006.

Notice how the computer performs operations by referring to the address of the memory cells. These addresses are a very important component in creating various data structures in computer memory. For example, suppose we want a data structure that can store a group of characters as a word. In many computer languages, this data structure is called a string. If we store the characters for the string 'apple' in the computer's memory, it might look something like this.

In order for the computer to recognize that 'apple' is a string, it must have some way of identifying the start and end of the characters stored in memory. This is why the addresses of the memory cells are important. By using the addresses to refer to a group of memory cells as a string, the computer can store many strings in a row to create a list. This is one way that we could create a data structure to represent our list of employees at company XYZ.

But what happens when we try to represent our tree diagram of company XYZ? It doesn't make sense to store the names one after the other because the tree is not linear. Now we have a problem. We want to represent a nonlinear data structure using computer memory that is linear. In order to do this, we are going to need some way of mapping nonlinear structures like trees or spreadsheet tables onto linear computer memory. In the next lesson we will see one solution to this problem.