lab02 : Trie

num ready? description assigned due
lab02 true Trie Thu 01/28 09:00AM Wed 02/03 11:59PM

Goals

By the end of this lab, given a description of a class containing data members and methods, you will be able to:

For this lab, you will only need to upload your trie.cpp to Gradescope, so please do not modify any other files.

#Step by Step

Step 0: Getting Started

This lab may be done solo, or in pairs. Before you begin working on the lab, please decide if you will work solo or with a partner. As stated in previous labs, there are a few requirements you must follow if you decide to work with a partner. I will re-iterate them here:

Step 1: Copying some programs from my directory

Visit the following web link—you may want to use “right-click” (or “control-click” on Mac) to bring up a window where you can open this in a new window or tab:

Lab02 Files

You should see a listing of several C++ files. Please copy those files into your local lab02 Github repo directory.

If so, you are ready to move on.

Step 2: Understand the Code and Finish trie.cpp

Trie is a data structure that is used to save a word list efficiently. Its introduction can be found here. And another visualization tool of Trie structure can be found here

In this lab, you will implement the Trie structure and some algorithms to manipulate it. The declaration of Trie structure is in the head file ‘trie.hpp’. The default constructor, copy constructor, destructor, overloaded ‘=’ operator, the functions used to insert a word, to check if a word is in the Trie, to get one word with a given prefix, are to be implemented in the file ‘trie.cpp’. There also include two functions loading a Trie from in-stream and a file. The details of these functions can be found in the given ‘trie.cpp’ file.

In these implementations, neither the length of the word nor the length of the input string is specified. That means recursion could be used for the trie structure. So as a hint, most of the functions are recursive. After you’ve designed the functions in ‘trie.cpp’, which should be submitted on Gradescope, you should write a test file to check if they are correct.

The input word may contain any character, including special characters. However, we only want to store letters of alphabets to tries and ignore any other characters. More specific implementation hints can be found in the comments in trie.cpp file. Please consider the input ‘str’ can also be NULL or an empty string, “”. You will also handle cases where the prefix ‘str’ has a length longer than the word itself.

Step 3: Test Your Code and Upload to Gradescope

The Autograder will use some test cases to check if your implementations are correct. In order to verify them, you’ll need to write your own test code, which can be a ‘main’ function to print out the results, before the submission. Then, write a Makefile to link all dependencies to make and run your test. The lab assignment “Lab02” should appear in your Gradescope dashboard in CS 24. If you haven’t submitted anything for this assignment yet, Gradescope will prompt you to upload your files. For this lab, you will only need to upload your modified file (i.e. trie.cpp). If you already submitted something on Gradescope, it will take you to their “Autograder Results” page. There is a “Resubmit” button on the bottom right that will allow you to update the files for your submission. For this lab, if everything is correct, you’ll see a successful submission passing all of the Autograder tests.

Remember to add your partner to Groups Members for this submission on Gradescope if applicable. At this point, if you worked in a pair, it is a good idea for both partners to log into Gradescope and check if you can see the uploaded files for Lab02.