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

This homework concerns the array, simple linked list, and hash table data struct

ID: 3773635 • Letter: T

Question

This homework concerns the array, simple linked list, and hash table data structures that all have been covered during the course. Description The IT engineers at AlAhli hospital want to modify the structure of the hash table they are using to store the patient lists at the Emergency Service. They want to change from a hash table with linear probing to a hash table with separate chaining. We will modify the classes and methods in files hash.java and hashChain.java (see lecture “cmps303-lecture 15-hashing” on blackboard) to help AlAhli engineers realizing their project. Please note that the patient information should at least include: qatarID: a String, which plays the role of the key, indate: a String representing the date of admission to the emergency service. Questions: 1. Adapt the classes and methods of the two files hash.java and hashChain.java to take into account the patient information as specified above. Note that you may also need to change the names of some classes to avoid compiling and linkage conflicts (e.g. the hash table classes could be: simpleHashTable and chainHashTable). 2. In the main(), create one variable sht instance of simpleHashTable, fill the table with few patients and display its content. 3. Do the same as in step 2 for the class chainHashTable. 4. To allow the IT engineers to migrate their data from the old system to the new one, develop, hashCopy, a new private function of the class chainHashTable to be called by the constructor of this class to create an instance of chained hash table from an instance of simple hash table. 5. In the main(), declare a new variable cht2 instance of simpleHashTable, create the table from the sht table created in step 2 and display its content. Make sure that the outcome of this step is exactly the same as step 2. 6. Write another private function, name it resize(), of the class chainHashTable to be called by the insert function of this class when the load factor reaches 75%. The resize() function will double the size of the array. 7. Test the function resize() in the main().


Explanation / Answer

package hashchain;
import java.util.LinkedList;
import java.util.List;


public class HashChain<ArbitaryType> {

    public HashChain() {
        this( );
    } // END CONSTRUCTOR
  

    public HashChain( int quantity) {
        chain1 = new LinkedList [ nextPrime(quantity)];
        int l;
        for (l = 0; l < chain1.length; l++   )
            chain1[l] = new LinkedList<ArbitaryType>();
      
    } // end public hash chain (int)
  
    public void pushIn(ArbitaryType varP)   {
        List<ArbitaryType> chain2 = chain1[ hashFunc(varP)];
        if ( !chain2.contains(varP))    {
            chain2.add(varP);
            // shuffle up the hash table
            if ( ++currentSize > chain1.length)     rehash();
        } // end if
    } // end pushIn
  
    public void delete( AnyType p) {
        List<AnyType> chain2 = chain1 [ hashFunc (varP)];
        if (chain2.contains(varP)) {
            chain2.remove(varP);
                currentSize--;
        }
          
    }
  
    public static void main(String[] args) {
        HashChain<Integer> Hash = new HashChain<Integer>();
        int UPPER = 56750;
        int INBETWEEN = 25;
        int l;
        //for (int l = INBETWEEN;)
      
      
    } // end main
  
} // end public Class HashChain

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