August 2020
Intermediate to advanced
508 pages
11h 53m
English
These are the solutions to the exercises found in the section, Exercises. The solutions provided here are in Python, but you can find the solutions in JavaScript and Ruby in the code download.[16]
This trie stores the words: “tag,” “tan,” “tank,” “tap,” “today,” “total,” “we,” “well,” and “went.”
Here is a trie that stores the words “get,” “go,” “got,” “gotten,” “hall,” “ham,” “hammer,” “hill,” and “zebra”:

The following code starts at the trie’s node and iterates over each of its children. For each child, it prints the key and then recursively calls itself on the child node:
| | def traverse(self, node=None): |
| | currentNode = node ... |
Read now
Unlock full access