Hashing Flashcards

1
Q

What are the desired properties of a hash function

A
  • Fast and easy to compute
  • Even spread of keys
  • Table size should not be ‘much larger’ than the number of entries.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is one of the main problems with universal hashing

A

for any function there exists a set of entries that all hash to the same location

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

what are two commonly used strategies to reduce collisions

A

Seperate chaining: a hash tab;e of lists
open addressing: find a new position in the hash table

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

What are dynamic arrays?

A

Arrays where we start with a reasonable capacity, then when that capacity is reached double it.

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

What is the amortised analysis of dynamic arrays?

A

Copying the old array takes time Omega n
So in worst case adding a new element may require Omega n

However, the new array allows adding n more elements before the size is increased again

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

What is the consequence of the amortised analysis of dynamic arrays?

A

Many simple add operations for each expensive one mean it averages out to be efficient in terms of runtime

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

What is the total runtime of n add operations in dynamic arrays?

A

Theta n

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

What is the amortised runtime of each add operation?

A

theta 1 (const)

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

What is the worst case runtime of each add operation?

A

Theta n

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