Page 187 -
P. 187
hash it out
SOlUTion
You were asked to match the data structure names on the left with
their descriptions on the right. You were also to identify which one you
thought you might need to use for the surfer data.
Array A variable that allows data to enter
at one end of a collection and leave
at the other end, supporting a first-in,
first-out mechanism
Linked list A variable that contains data arranged
as a matrix of multiple dimensions
(but typically, only two)
Here's the Queue A variable that has exactly two
one you columns and (potentially) many rows
need. of data
Hash A variable with multiple indexed slots
for holding data
A variable that creates a chain of data
where one data item points to another
Set
data item, which itself points to
another data item, and another, and
so on and so forth
Multi-dimensional array A variable that contains a collection
of unique data items
Known in the Python world
as a “dictionary.”
Use a hash Geek Bits
You need to use a data structure that maintains the
association between the surfer score and the surfer name,
which is exactly what a hash gives you. There are lots of Hashes go by different names in
surfers with lots of scores, and you need to maintain the different programming languages:
association between the two pieces of information. mapping, dictionary, associative array, and
key-value list, to name a few. In this book,
Let’s take a look at how hashes work. we’ll stick to using the name hash.
152 Chapter 5 This cuts down on the amount of typing and saves our poor fingers!