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

Java Programing: Compare times per single search between HashSet and TreeSet col

ID: 640340 • Letter: J

Question

Java Programing:

Compare times per single search between HashSet and TreeSet collections.

Select and store words from 2 books by the same author in 2 separate sets (use www.gutenberg.org). Use one of these sets to search word-by-word in the other set. Measure time per each search. Show results from this experiment along with your conclusion. Also submit code.

Use these two books by Charles Dickens:

https://www.gutenberg.org/files/24022/24022-0.txt

https://www.gutenberg.org/cache/epub/1400/pg1400.txt

Explanation / Answer

HashSet is much faster than TreeSet (constant-time versus log-time for most operations like add, remove and contains) but offers no ordering guarantees like TreeSet.

HashSet:

TreeSet:

Important points:

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