Exercises
The following exercises provide you with the opportunity to practice with tries. The solutions to these exercises are found in the section, Chapter 17.
-
List all the words stored in the following trie:
-
Draw a trie that stores the following words: “get,” “go,” “got,” “gotten,” “hall,” “ham,” “hammer,” “hill,” and “zebra.”
-
Write a function that traverses each node of a trie and prints each key, including all "*" keys.
-
Write an autocorrect function that attempts to replace a user’s typo with a correct word. The function should accept a string that represents text a user typed in. If the user’s string is not in the trie, the function should ...
Get A Common-Sense Guide to Data Structures and Algorithms, Second Edition, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.