• Home
  • Blog
  • Compare the CPU and memory efficiency between HashSet and TreeSet​

Compare the CPU and memory efficiency between HashSet and TreeSet​

0 comments

You must include your name in every file that you submitted.

You are not allowed to submit binary files, including zip files, image files, and bytecodes.

Please name your Java file/class as YourLastNameQZ3.java, e.g., YaoQZ3.java

Objective: Compare the CPU and memory efficiency between HashSet and TreeSet

Input files: qz3Data.csv and qz3ID.txt

Assumption: The number of records in qz3Data.csv is unknown

The data file “qz3Data.csv” is a csv (comma separate value) file and contains 6 fields, separated by commas,
on each line:

ID, City, State, Zip Code, Amount, Date

Listed below are some sample lines:

71300cc5-d751-57c9-ba81-4a69e48745d1,Bisuhub,RI,53353,$6534.03,09/08/2070

78f52baf-91fe-5861-9659-24f38a539018,Dekgiihi,GA,13754,$776.26,03/04/1916

You are required to develop a Java program to:

1. Read all data records from qz3Data.csv file into java.util.HashSet and java.util.TreeSet.

2. Display the memory used by HashSet created in step 1.

3. Display the memory used by TreeSet created in step 1.

4. Read one ID from qz3ID.txt and search against HashSet created in the step 1. Repeat this operation for all
IDs in qz3ID.txt. Display the CPU Time used for this operation.

5. Read one ID from qz3ID.txt and search against TreeSet created in the step 1. Repeat this operation for all
IDs in qz3ID.txt. Display the CPU Time used for this operation.

Hint: This program generates 4 lines of putput.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}