Hashing Flashcards

(21 cards)

1
Q

What are the two main types of access structures discussed?

A

Direct access structures and linear access structures

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

What is a major disadvantage of direct access structures?

A

Need to allocate size in advance

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

What issue arises when overestimating the size of a direct access structure?

A

Ends up with a very sparse structure

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

In hash tables, how is a key k stored?

A

Stored in slot hash(k)

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

What is the function that maps the universe of keys into the slots of a hash table?

A

h : U –> {0,1,…,m-1} where m is the size of the table

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

What is a characteristic of a good hash function?

A

Satisfies the assumption of uniform hashing

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

What is the division method based on in hash functions?

A

Where m is the size of the hash table

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

What is a good choice for the size m of a hash table?

A

Prime numbers that are close to n divided by the number of desired average probes

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

What does the multiplication method depend on?

A

A constant A between 0 and 1

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

What is the importance of order preservation in hash functions?

A

Similar to the stability property in sorting

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

What are the two classes of collision resolution in hash tables?

A
  • Separate chaining
  • Open addressing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does separate chaining involve?

A

Mixing linked lists and direct access structures

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

What happens when a collision occurs in a hash table using separate chaining?

A

The new key is stored in the linked list at that location

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

What is the purpose of the hash function h(k) = k mod size?

A

To create hash values for integer keys

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

What is the worst-case performance of hash search?

A

O(n)

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

What is the average-case performance of hash search if m = O(n)?

17
Q

What does linear probing suffer from?

A

Primary clustering

18
Q

What is a technique used in open addressing that involves adding a squared term?

A

Quadratic probing

19
Q

What is the risk associated with random probing?

A

Suffers from secondary clustering

20
Q

What is rehashing in the context of hash tables?

A

A technique where a sequence of hashing functions is used in order

21
Q

What is the method to search for a target in a hash table?

A

Hash the target and search in the linked list at the corresponding slot