

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
Material Type: Exam; Class: ALGS/DATA STRUCTURES; Subject: COMPUTER SCIENCE; University: Clemson University; Term: Fall 2005;
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) { public void delete (int x) { // … inserts x into hash table // … deletes x from hash table } // insert // NOTE: for 5-pt bonus credit } // delete 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 : [53, -1, -1, -1, -1, 72, -1, -1, -1, -1, -1, -1, 91, -1, -1, 15, 34, -1, -1]