Linked List Game
Props: 5 or 6 large cards representing the information stored
in a node. Use characters or something fitting to the season, such as
pictures of easter eggs. A yellow Post-it.
Description: Ask for a volunteer (or pick the guy that makes
the most noise in class, usually this is a person who wants attention)
to come up front. He is our anchor variable and gets a name assigned
by having a post-it stuck on him somewhere. Ask him to hold his left
hand in the air - a dangling pointer if there ever was one! Now have
another volunteer or the second most loud person come up. Give them a
card - this is the node information. Have the anchor point to this NEW
person. Where's the null pointer now? Continue for a few more persons,
until they have the idea. Insert a node between two nodes to give them
an idea of the algorithm involved in this operation.
This exercise gives the students an
excellent opportunity to discuss pointers, even if they have not yet
learned to use words like pointer and pointer object correctly. One
student once asked after the game the next week: if I am pointing to
my friend, can someone else point to him at the same time? And we
launched a great conversation on the difference between pointers and
objects, aliases (multiple references), dangling pointers etc. They
had the vocabulary and a structure in mind, and could work with
them!