Hashing and finding closest points Flashcards

1
Q

What is a dictionary data structure?

A

A dictionary is a data structure that supports MakeDictionary

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

What is the universe U in the context of dictionaries?

A

The universe ( U ) is the set of all possible elements that could be part of the subset ( S ) maintained by the dictionary.

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

Why is hashing used for dictionaries?

A

Hashing allows efficient dictionary operations by mapping a large universe ( U ) into a smaller hash table using a hash function.

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

What is a hash function?

A

A hash function maps elements from the universe ( U ) to positions in a smaller array (hash table) to store and retrieve elements efficiently.

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

What is a collision in a hash table?

A

A collision occurs when two different elements ( u ) and ( v ) are mapped to the same hash table position by the hash function.

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

How does chaining resolve hash collisions?

A

In chaining

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

What are the operations supported by hash tables?

A

Hash tables support Insert (add an element), Delete (remove an element), and Lookup (check membership and retrieve data).

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

What makes a hash function ‘good’?

A

A good hash function minimizes collisions by distributing elements uniformly across the hash table.

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

What is the probability of a collision in uniform random hashing?

A

With uniform random hashing, the probability that two random elements collide is exactly ( 1/n ), where ( n ) is the size of the hash table.

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

What is a universal class of hash functions?

A

A universal class of hash functions ensures that for any two distinct elements ( u ) and ( v ), the probability that ( h(u) = h(v) ) is at most ( 1/n ).

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

What is the advantage of universal hash functions?

A

Universal hash functions ensure efficient dictionary operations by reducing the likelihood of collisions, even in the worst case.

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

How is a universal hash function constructed?

A

A universal hash function can be constructed using linear functions modulo a prime ( p ), such as ( h(x) = (\sum a_i x_i) \mod p ).

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

Why is a prime ( p ) used in universal hashing?

A

Using a prime ( p ) ensures that modular arithmetic avoids divisibility issues, providing better collision guarantees.

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

What is the complexity of dictionary operations using hashing?

A

With universal hashing, the expected complexity of Insert, Delete, and Lookup operations is ( O(1) ).

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

How are hash tables used in the closest-pair algorithm?

A

Hash tables help divide the unit square into subsquares, allowing efficient Lookup of nearby points during the closest-pair algorithm.

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

What is the expected time complexity of the randomized closest-pair algorithm?

A

The algorithm runs in ( O(n) ) time for processing points plus ( O(n) ) dictionary operations.

17
Q

Why is randomness used in the closest-pair algorithm?

A

Randomness is used to order points and in hash functions, ensuring efficiency and reducing worst-case scenarios.

18
Q

What are subsquares in the closest-pair algorithm?

A

Subsquares divide the unit square into regions of side length ( \delta/2 ), used to group points for efficient distance computation.

19
Q

What is the significance of the subsquares’ properties?

A

Subsquares ensure that only nearby points need to be checked for distances less than ( \delta ), reducing unnecessary computations.

20
Q

How does the closest-pair algorithm update its state when ( \delta ) changes?

A

When ( \delta ) decreases, a new dictionary is created with updated subsquares, and all points are reinserted.

21
Q

What is the relationship between hash table collisions and dictionary performance?

A

Fewer collisions lead to shorter chains in hash table entries, improving the efficiency of dictionary operations.

22
Q

How is a hash value computed efficiently in universal hashing?

A

Hash values are computed using linear functions with modular arithmetic, requiring ( O(\log N / \log n) ) operations for ( n ) elements.

23
Q

Why is universal hashing effective for dynamic dictionaries?

A

Universal hashing minimizes collisions across arbitrary input sets, ensuring efficient operations even with adversarial input.

24
Q

How does randomization in hashing improve performance?

A

Randomization spreads elements uniformly across the hash table, reducing the chance of clustering and long chains.

25
Q

What is the expected number of Insert operations in the closest-pair algorithm?

A

The expected number of Insert operations is ( O(n) ), as updates to the closest pair become less frequent over time.

26
Q

How do dictionary operations contribute to the overall complexity of the closest-pair algorithm?

A

Efficient dictionary operations ensure the total work remains ( O(n) ) in expectation, matching the algorithm’s computational efficiency.