August 2024
Intermediate to advanced
516 pages
11h 47m
English
These are the solutions to the exercises found in the section Exercises.
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:
| | traverse(node = null) { |
| | const currentNode = node || this.root; |
| | |
| | for (const [key, childNode] of Object.entries(currentNode.children)) { |
| | console.log(key); |
| | |
| | |
Read now
Unlock full access