

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about a programming assignment for a computer science course, specifically for creating a myhashtable class with insert and tostring methods, and an optional delete method. Students are required to use a primary hash function and double hashing to handle collisions. An example test driver and submission instructions.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


public MyHashTable (int n) { // ... your code ... } // MyHashTable
public void insert (int x) { // … inserts x into hash table } // insert public String toString () { // ... your code ... } // toString
public static void main(String args[]) { MyHashTable h = new MyHashTable(19); System.out.println("Initial hash table: " + h); int v = 15; h.insert(v); System.out.print("Inserted " + v); v += 19; h.insert(v); System.out.print(", " + v); v += 19; h.insert(v); System.out.print(", " + v); v += 19; h.insert(v); System.out.print(", " + v); v += 19; h.insert(v); System.out.print(", " + v); System.out.println("\nAfter inserts : " + h); } // end main
Initial hash table: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] Inserted 15, 34, 53, 72, 91 After inserts : [-1, 72, -1, -1, 91, -1, 34, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 53, -1]