ITSC 2214 RealizeIT Week 12
What does a hash table that uses separate chaining and has a size of 7 look like if you use the hash function "k%7" to insert the keys 5, 29, 20, 0, and 18?
0, 20, , , 18, 5, 20
In the code below, what value is stored in result? HashMap<String, Integer> hm = new HashMap<String, Integer>(); hm.put("Apples", 5); hm.put("Oranges", 7); hm.put("Oranges", 2); Integer result = hm.get("Oranges");
2
A hash table is intended to store lots of information about events that occur throughout history after 0 AD. The key is the date of the corresponding event. What is an appropriate combination of number of buckets and hashing algorithm? (Assume Year is the year after 0 AD and Day is the day of the year, and not the day of the month)
365000 buckets, <(Year *="" 365)="" +="" day=""> mod 365000
Which of the following operations has a different Big O complexity than the others?
Accessing an element in a well-designed hash table
What is a hash table?
An array
Using separate chaining to resolve hash collisions, after inserting the following five items into a hash table of capacity 5, in the order given, what does the hash table look like? Key Hash code A 1 B 1 C 1 D 0 E 2
D, C->B->A, E
Using separate chaining to resolve hash collisions, after inserting the following five items into a hash table of capacity 5, in the order given, what does the hash table look like? Key Hash code A 0 B 1 C 2 D 0 E 2
D->A, B, E->C, empty, empty
What is the load factor for a hash table?
The percentage full at which you increase the size of the hash table
Using Java's built in Hash Map, what would be the best way to remove all values currently contained in a map?
clear()
If a hash function is given a StudentRecord object as an input, what will the hash function produce?
int
HashMap<Integer, Boolean> hm = new HashMap<Integer, Boolean>(); In the hash map above, the ___ are Integers and the retrieved values are Booleans.
key
A perfect (or direct) hash function requires:
that every key value maps to a unique index
A hash table of 5 buckets uses sequential chaining and a hashing algorithm that performs modulus division on a key's 'score' field. The following keys and values are entered into the hash table in order. What is the resulting hash table? | Key Score | Value | | --- | --- | | 04 | "Apple" | | 40 | "Banana" | | 23 | "Orange" | | 11 | "Grapefruit" | | 13 | "Lime" | | 44 | "Kiwi" | | 72 | "Lemon" |
| Index | Contents | | --- | --- | | 0 | "Banana" | | 1 | "Grapefruit" | | 2 | "Lemon" | | 3 | "Lime" -> "Orange" | | 4 | "Kiwi" -> "Apple" |