New Term: One way to solve this problem is with a linked list. A linked list is a data structure that consists of small containers that snap together. The idea is to write a class that holds one object of your datasuch as one CAT or one Rectangleand that can point at the next container in the list. You create one container for each object that you need to store, and you chain them together as needed.
The containers are called nodes. The first node in the list is called the head, and the last node in the list is called the tail.
Lists come in three fundamental forms. From simplest to most complex, they are
Singly linked
Doubly linked
Trees
New Term: In a singly linked list, each node points to the next one, but not backward. To find a particular node, you start at the top and go from node to node, as in a treasure hunt (The next node is under the sofa.) A doubly linked list enables you move backward and forward in the chain. A tree is a complex structure built from nodes, each of which can point in two or three directions. Figure 19.1 shows these three fundamental structures.
Computer scientists have created even more complex and clever data structures, nearly all of which rely on interconnecting nodes.