Page 1 of 1

The options for the boxes are 100000, 120000, 250000, 1, true, false, name.len(), HTABLE_SIZE, key, j, index, compareTo

Posted: Sun May 15, 2022 1:37 pm
by answerhappygod
The Options For The Boxes Are 100000 120000 250000 1 True False Name Len Htable Size Key J Index Compareto 1
The Options For The Boxes Are 100000 120000 250000 1 True False Name Len Htable Size Key J Index Compareto 1 (32.64 KiB) Viewed 62 times
We need to store roughly 100000 names for fast, random retrieval. Below are some code segments and functions that define the table and provide insert and searching operations in unchained hash table. Collisions are resolved with linear probing. Fill in the blanks appropriately. Answer the questions at the bottom too. public static final int HTABLE_SIZE = ; //need decent size //for performance but not use too much space String name; //hold the current name String name Tab[HTABLE_SIZE]; //the hash table public int hash(String name) {//add up the unicodes of the characters of the name int key = 0; for(j=0; j< ; j++) key = key + .charAt( ; // weight letter by position return (key % ); } public int search(String name) //POST: returns position in hashtable where name should be located { int index = hash ); while (nameTab[index] != null && nameTab[index]. (name)!=0) { index = (index + ) % } return ; //note the slot is null if search fails

public boolean insert(String name) //POST: insert the string into the hash table and return true; //return false if already there { //inserts name into table int index; // where it is or where it should go index = search(name); // using the search to locate position if (name Tab[index]!=null){ // then already there return } else { // can insert instead name Tab[ ] = return } } What kind of hash function is in use? . What is the load factor for this and most hash tables?