Question: Implement in the P4e3 client class a method that will generate random integer keys, which will follow a uniform distribution (using the appropriate method of
Implement in the P4e3 client class a method that will generate random integer keys, which will follow a uniform distribution (using the appropriate method of the StdRandom.java class, included in algs4.jar) and insert them into an initial size N / 100 hash using the SeparateChainingHashST.java class (https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/SeparateChainingHashST.java.html). The method will accept N as a parameter. Try for N = 103, 104, 105, 106. For each value of N the results will be displayed as follows:
The final size of the hash table
N, the number of key-value pairs in this symbol table, the length of the largest synonym chain, the length of the smallest synonym chain All keys of the largest chain of synonyms (separated by 1 space) All keys of the smallest chain of synonyms (separated by 1 space) To display the results you will need to add 5 methods to the SeparateChainingHashST.java class which will find and return respectively a) the length of the largest synonym chain b) the length of the smallest synonym chain c) all the keys of the largest synonym chain d ) all the keys of the smallest chain of synonyms, e) the size of the hash table. An indicative execution snapshot is given for N = 103
Hash table size = 80 N = 1000, Number of key-value pairs = 643, max chain size = 27, min chain size = 15 ----MinChain---- 2 154 393 806 772 19 32 169 535 442 655 290 685 958 565 ----MaxChain---- 65 217 716 869 458 488 884 475 581 200 99 854 323 234 991 596 251 114 974 368 733 750 338 615 80 767 630
Solution with Java please!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
