Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Weekly Problem: Using Sets and Maps As explained in the textbook, a TreeSet uses

ID: 3787096 • Letter: W

Question

Weekly Problem: Using Sets and Maps As explained in the textbook, a TreeSet uses a data structure called a binary search tree to keep the elements it stores in sorted order. This is useful if you need the elements to be ordered, but it tends to make the TreeSet a bit slower than HashSet. In this weekly exercise you will explore how the time efficiency of the two types of Sets differs. To complete your analysis, you arc to do the following: Choose 2 books (BookA and BookB) by the same author (use www.gutenberg.org). Store the words in each of the books in a TreeSet and in a HashSet (make sure to close and open the files, if you are loading the words into the above data structures individually). After this, you should have a total of 4 sets: BookA_hash. BookA_tree. BookB_hash. BookB_tree. Iterate through the words in BookA.hash and search for these words in both BookB_tree and in BookB_hash. Iterate through the words in Book A_tree and search for these words in both BookB_tree and BookB_hash. Iterate through the words in BookB_hash and search for these words in both BookA_tree and in BookA_hash. Iterate through the words in Book B_tree and search for these words in both BookA_tree and BookA_hash. Keep track of the time each search took (you should have results from 8 searches total: sec this for timing your program: http://iavarcvisitcd.blogspot.com/2Q12/Q4/how-to-mcasurc-clapsed-cxecution-time.html) and note them down using a spreadsheet (see 8 below). From your results, what do you conclude about the time required to iterate through each Set type? About the time to search through each Set type? Submit both your code and your results (nicely formatted as a table please) and responses from part 7. In order to earn maximum score in this exercise. I should be able to easily understand the structure of your program (use procedural design and comment well) and a clear presentation and summary of your results from this code bench-marking experiment.

Explanation / Answer

import java.io.*;

import java.util.*;

public class Problem { private static Set<String> BookA_Hash = new HashSet<String>();

private static Set<String> BookA_Tree = new TreeSet<String>();// Hash is stored linked,tree is ordered

import java.io.*;

import java.util.*;

public class Problem { private static Set<String> BookA_Hash = new HashSet<String>();

private static Set<String> BookA_Tree = new TreeSet<String>();// Hash is stored linked,

import java.io.*;

import java.util.*;

public class Problem { private static Set<String> BookA_Hash = new HashSet<String>();

private static Set<String> BookA_Tree = new TreeSet<String>();// Hash is stored linked,tree is ordered

public class Problem { private static Set<String> BookB_Hash = new HashSet<String>();

private static Set<String> BookB_Tree = new TreeSet<String>();import java.io.*;

import java.util.*;

public class Problem { private static Set<String> BookA_Hash = new HashSet<String>();

private static Set<String> BookA_Tree = new TreeSet<String>();// Hash is stored linked,tree is ordered

public class Problem { private static Set<String> BookB_Hash = new HashSet<String>();

private static Set<String> BookB_Tree = new TreeSet<String>();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote