August 2020
Intermediate to advanced
508 pages
11h 53m
English
Because hash tables keep data in pairs, they are useful in many scenarios for organizing data.
Some data exists naturally in paired form. The fast-food menu and thesaurus scenarios from this chapter are classic examples of this. The menu contains each food item paired with its price. The thesaurus contains each word paired with its synonym. In fact, in Python, hash tables are known as dictionaries since a dictionary is a common form of paired data: it’s a list of words with their respective definitions.
Other examples of naturally paired data can include tallies, such as political candidates and the number of votes each received:
| | {"Candidate A" => 1402021, "Candidate B" => 2321443, "Candidate C" => 432} |
Read now
Unlock full access