RealizeIT Week 12

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the load factor for a hash table?

The percentage full at which you increase the size of the hash table

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" |

Most hash functions involve the use of what operator?

%

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 accurately describes hash tables?

A well-designed hash table has effectively O(1) access to elements.

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 a hash function?

It maps key values to array indices

What is a hash function?

It maps key values to indices

The benefit of using hash functions is that access to elements is typically:

O(1)

What is the efficiency of searching a hash table that uses names as the hash key, if you are searching by name?

O(1)

Which of the following operations has a different Big O complexity than the others?

Searching a binary tree

A collision occurs when:

Two key values map to the same index

Using Java's built in Hash Map, what would be the best way to remove all values currently contained in a map?

clear()

Which data structure is most useful for looking up people by their social security number?

hash table

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

The circuit() method is intended to take the distance a person has moved on a circuit (a track) and translate it into the position they would be at, regardless of how many times they've gone around. If the input n is the number of yards traveled, and the circuit itself is 198 yards in circumference (labeled 0 to 197), which of the following would correctly complete the method? public int circuit(int n) { int location = __________; return location; }

n % 198

A perfect (or direct) hash function requires:

that every key value maps to a unique index

A perfect/direct hash function requires:

that every key value maps to a unique index


संबंधित स्टडी सेट्स

Ch. 3 - Ethics and Criminal Justice Research (W8)

View Set

Chapter 6 The Flow of Food: Purchasing and Receiving

View Set

AP Govt Key Constitutional Clauses

View Set

cultural anthropology final exam

View Set

NURS 3102 Quiz 3: Patient Education and Technology

View Set