Project: Tries

1. Introduction

The goal of this project is to understand how to use tries to implement a set (modifying this to implement a map or bag would be pretty simple).

My intention was that this project be lighter-weight, an easier one to finish up the semester with. It easily could have been a nasty one, however. But I'm going to put the hard parts into a series of "bonus" exercises, which you can try for extra credit. [Do not attempt to do the bonus exercises as a replacement for earlier exercises. That is a very bad strategy and violates the intention of "extra credit." Extra credit is for the occupation of students who have already done the required stuff, not to compensate for missing the required stuff.]

This project is found as Project 8.1 in the book, pg 612. Actually, this wasn't ready by "press time" last fall, so it's not in the manual you bought from the bookstore. Instead, refer to the pdf of Chapter 8 available on Schoology.

2. Set up

Find the project code for this and the next project at /homes/tvandrun/Public/cs345/trie. As usual, the code is organized into the packages adt, impl and test, but adt and imple each have only one file.

Familiarize yourself with the given code in impl/TrieSet. A trie is a tree whose nodes each have a letter and as many children (potentially) as there are letters. If a string is in the set that this trie represents, then there is a path in the tree from the root to a node following the letters in that string. But the converse isn't true: just because a path in the tree exists following the letters of a certain string doesn't mean that string is in the set: it might merely be a prefix of a string that is in the set. Thus each nodes needs a tag indicating whether it is terminal---whether it is the end of a path indicating a string in the set. Note that not all terminal nodes are leaves, though all leaves ought to be terminal nodes---otherwise they're wasting space being in the tree.

3. Implementing basic functionality

Do parts a-e.

4. Bonus problems

There are a bunch of harder problems that one could solve. Too bad the semester has to end. If you have some extra time after the required part of this project (and all other projects), here are a few nifty problems to trie, I mean, try. I'll give some extra credit for each of these you do (but don't do these in place of completing an earlier project, do it for the fun/challenge).

For bonus problems, do parts f-j

5. Turn in

Copy the file you modified (TrieSet.java) to your turn-in folder /cslab/class/cs345/(your id)/trie .

To keep up with the course, this should be finished by May 4, which is also the hard deadline for all projects in this course.


Thomas VanDrunen
Last modified: Mon Mar 16 16:08:39 CDT 2020