Chapter 5 (Hashing) Flashcards

1
Q

Table size should be a ____ ____

A

Prime number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In perfect hashing, what is the worst case access time?

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a drawback of the chaining method?

A

Allocating new nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the formula for the expected number of probes in a linear probing strategy?

A

1/(1-lambda)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the worst case running time for a find in hopscotch hashing?

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

T/F Java hash tables require the “equals” and “hashCode” methods to be defined on the hashed objects

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How many hash tables does cuckoo hashing use?

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does separate chaining handle collisions?

A

Each index contains a list. Each item that collides is contained in this list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is primary clustering?

A

A large list of values clustered around the same cell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the primary drawback of linear probing?

A

Primary clustering

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is it called when two keys map to the same location?

A

Collision

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is lambda?

A

The ratio of the number of elements to the table size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the job of the hash function?

A

Mapping

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the average running time for inserts, deletes, and finds for hashing?

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

T/F Hashing supports operations like findMin and findMax

A

F

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the worst case access time in cuckoo hashing?

17
Q

What is rehashing?

A

When a table is 50% full, create a new table twice the size of the old one and rehash everything to the new table

18
Q

How can duplicates be handled with separate chaining?

A

Having a counter on each element

19
Q

What does Horner’s rule give us?

A

A simple way to compute a polynomial using multiplication and addition

20
Q

In perfect hashing, what is the space required?

21
Q

What is the strategy of quadratic probing?

A

First look 1 away, then 4, 9, 16, 25, etc.

22
Q

If we want to hash 100 elements into a table size of 100, what would lambda be?

23
Q

T/F Open addressing requires a large table

24
Q

How can you keep the likelihood of a cycle in cuckoo hashing very small?

A

Keep the load < 0.5

25
In double hashing, what is done to resolve a collision?
A second hash function
26
What is the scheme of perfect hashing?
Each secondary table can be constructed several times until it is collision free
27
What problem does quadratic probing introduce?
Secondary clustering
28
What is a downside of double hashing?
Likely to be slower than quadratic probing
29
T/F The hashing function should be a simple algorithm that distributes the keys evenly among the cells
T
30
What are three common collision resolution strategies?
Linear probing Quadratic probing Double hashing
31
What is done if sliding in hopscotch hashing is unsuccessful?
Rehash
32
How does open addressing resolve collisions?
By storing a colliding element in an alternate cell
33
In universal hashing, what is the probability of a collision if a hash function is chosen at random?
1/M
34
T/F Each secondary table can be constructed several times until it is collision free
T
35
In linear probing, cells are tried ____ until an empty cell is found
Sequentially
36
With a lambda of 1.0, what should the average list be?
1 node
37
What does quadratic probing help prevent?
Primary clustering
38
In open addressing, how is the alternate cell chosen?
By another function called the collision resolution strategy
39
For ints, how does a hash function convert keys to indices?
key % tableSize