CS 231: Project #7

Title image Spring 2018

Trees v. Tables

The main purpose of this project is to give you the opportunity to examine the efficiency of your Hashmap and your BSTMap when counting words in the Reddit comment files.

Tasks

  1. Modify your WordCounter class from last week. Instead of having a field of type BSTMap<String, Integer>, use a field of type MapSet<String, Integer>. In the constructor, require a parameter that selects whether the WordCounter will use a BSTMap or a Hashtable for storing the data.
  2. Make sure your WordCounter main function is able to calculate the amount of time it takes to analyze a file using System.currentTimeMillis(). For example:

            long startTime = System.currentTimeMillis();
            wc.analyze( inputFilename );        
            long finishTime = System.currentTimeMillis();
            System.out.println("It took: "+(finishTime-startTime)/1000.0+ " second to read in the file of words");

  3. Use code like that above to make the WordCounter analyze the input file five times. Record each of the 5 times, drop the low time, drop the high time, and compute the mean of the remaining three (your WordCounter should do all of this, don't do this by hand). If you wish, automate the process for all eight of the Reddit files.
  4. Run the analysis using the BSTMap on all eight Reddit files and record the times in a spreadsheet or CSV file.
  5. Repeat the process using the Hashtable data structure. Record the times in a spreadsheet or CSV file.
  6. Use a spreadsheet program to report the numbers with a line graph or bar graph. The x-axis should be the file/year and the y-axis should be the runtime). If there are any trends, describe them. Which data structure appears to be faster on this data set? Include the graph or graphs in your report.
  7. Analyze the performance of the BSTMap and Hashtable to see how close to ideal they perform. For the Hashtable, that will involve counting collisions. For the BSTMap, that will involve determining the height of the tree. You may need to modify the BSTMap to calculate height. Include this analysis in your report.

Extensions

Each assignment will have a set of suggested extensions. The required tasks constitute about 85% of the assignment, and if you do only the required tasks and do them well you will earn a B+. To earn a higher grade, you need to undertake at least one extension. The difficulty and quality of the extension or extensions will determine your final grade for the assignment. One significant extension, or 2-3 smaller ones, done well, is typical.

  1. Use additional files to test the (time and/or space) efficiency of your implementations.
  2. Implement your own hash function. How does its performance compare to the built-in string hash function?
  3. Try implementing more than one collision handling method. For example, (1) use a linked list instead of a BSTMap at each table entry, or (2) use a closed hash table (no extra data structures). Compare performance.
  4. Examine the space efficiency of your implementations. One way to do this would be to refrain from using the -Xmx512m flag. Count words of files of increasing sizes. See what is the size of the smallest size that crashes your program. Does a smaller file crash the Hashtable code or the BSTMap code? Why?
  5. Improve the time-efficiency of one of your data structures. Explain what you did and report the improvement in speed.
  6. For any assignment, a good extension will be to implement a Java class yourself and demonstrate that it has the same functionality as the Java class. For example, you could implement your own ArrayList class for this assignment.
  7. For any assignment, a good extension will be to annotate your code to indicate all places where memory is "lost" (in other words, each place where the last remaining reference to an object is either destroyed or is given a new value). If you do this extension, please indicate so in your write-up.

Report

Your report should have a simple format.

Handin

Make your report for the project a wiki page in your personal space. If you have questions about making a wiki page, stop by my office or ask in lab.

Once you have written your report, give the page the label:

cs231s18project7

You can give any wiki page a label using the label field at the bottom of the page. The label is different from the title.

Do not put code on your writeup page or anywhere it can be publicly accessed. To hand in code, put it in your folder on the Courses fileserver. Create a directory for each project inside the private folder inside your username folder.