Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey, I need some help here. The code for the problem below is under the problem. Thanks! The Code: *************LqHashed Class*************** package lqhashed; public class

Hey, I need some help here. The code for the problem below is under the problem. Thanks!

image text in transcribedimage text in transcribedThe Code:

*************LqHashed Class***************

package lqhashed;

public class LqHashed {

public static void main(String[] args) {

} int N; int n = 0; // the number of nodes in the structure int defaultQuotient = 9967; // the default 4k+3 prime double loadingFactor = 0.75; Listing deleted; // the dummy node, v2 private Listing[] data; // the primary storage array public LqHashed(int length) { int pct = (int)((1.0/loadingFactor-1) *100.0); N = fourKPlus3(length, pct); data = new Listing[N]; deleted = new Listing("","",""); for(int i = 0; i 1; d--) { if(prime%d == 0) break; } if(d != 1) // prime not found prime = prime +2; else aPrime = true; }// end of the prime search loop if((prime-3)%4 == 0) fkp3 = true; else { prime = prime +2; aPrime = false; } }// end of 4k+3 prime search loop return prime; } public static int stringToInt(String aKey) // from Figure 5.18 { int pseudoKey = 0; int n = 1; int cn= 0; char c[] = aKey.toCharArray(); int grouping =0; while (cn

**********Listing class***************

package lqhashed;

public class Listing { private String name; // key field private String address; private String number; public Listing(String n, String a, String num ) { name = n; address = a; number = num; } public String toString( ) { return("Name is " + name + " Address is " + address + " Number is " + number + " "); } public Listing deepCopy( ) { Listing clone = new Listing(name, address, number); return clone; } public int compareTo(String targetKey) { return(name.compareTo(targetKey)); } public void setAddress(String a) // coded to demonstrate encapsulation { address = a; } public String getKey() { return name; } }// end of class Listing

Program 4 Dynamic Hashed Structure Re-code the student records problem using a dynamic version of the LQHashed structure. l After any of the four basic operations are performed, the following two lines should be output to the console by a method invoked before the operation methods' return statements: Pseudo loading factori Current densityi Search length Current loading factor 0.26 0.18 To compute the pseudo loading factor, y will have to add a data member to the data structure class keep track of the number of dummy references in the structure, which will increase every time a delete operation is performed and decrease whenever an insert operation overwrites a dummy reference. 2- When an insert operation is requested that would cause the current lo factor to exceed the optimum value (0.75), the primary storage area should be expanded to approximately twice its capacity before the node is inserted, and then the following line will be output to the console "Primary storage area was expanded. The array size is now N" Of course N must be a 4k+3 prime obtained from invoking the method fourkPlus3. The expansion should be accomplished using a new method in the data structure class invoked by the insert method. The new size of the array will be passed to it. It will rename the primary storage area array, then create the expanded primary storage area array, set N to its new value, and then invoke insert to reinsert all the nodes except the dummy nodes) back into the structure 3- Whenever an insert operation causes the pseudo loading factor to exceed the optimum value (0.75), use the expansion method to eliminate all of the references to the dummy<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago