For loopsTopChain ReactionLinkedLists: what targets, scribbles, and chain reactions have in common

LinkedLists: what targets, scribbles, and chain reactions have in common

We've been very careful to note the similarities in the examples we've considered in this lecture and the previous one. While targets, scribbles, and balls look very different on the surface, the data structures used to represent them have been strikingly similar. Obviously this is more than just an interesting coincidence. The type of data structure we've been looking at is one that is useful in many contexts. It is called a singly linked list.

The name singly linked list should be self-explanatory, but let's say a little more about it. The reason for calling this data structure a list is because it allows us to store a list of items: circles, lines, or balls. We call it singly linked because the way it is represented allows us to traverse it in one direction only. To "walk through" the list we always considered first first; then we stepped through the list until we reached the end. We never moved backward through the list.

When we build a general-purpose data structure to hold a collection of items, there are certain types of functionality we want them to have. We need to be able to:

The last of these we managed by being able to get the first element of the list as well as the rest of the list (recursively). While we didn't need to implement all of these for all of our examples, we illustrated each of these in at least one context. ogether in the context of the drawing program.
For loopsTopChain ReactionLinkedLists: what targets, scribbles, and chain reactions have in common