week 8 must recap before exam Flashcards

1
Q

linear probing

A

h’(x) = [ h(x) + i ] % N N - size i= 1,2,3 … N-1 (iterate when theres is a collision increasing value of i until you reach an empty cell)

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

chaining

A

uses link lists

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

hash function

A

h(k) = K Mod N ( k- value of key) and N - size

N is preferably prime to reduce likelihood of collision

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

MAD hash function

A

((ay+b) ModP ) Mod N

N - size and prefrably prime
p - prime greater than n
a and b - random integers [0, p-1] a > 0

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

In worst case search , insertions, removals on a hashtable is o(n) everything collides ( chaining where linked list is best example if everything collides you would have to traverse across every element in linked list

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

double hashing

A

h(k) = K Mod N
h’(k) = q - k Mod q

Q should be a prime less than N

if collision :
A[ ((h(k) + j x h’(k) ) Mod N ]

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

load factor alpha

A

m / N gives expected keys per slot

m - the no of keys
N - the size of the array

if load factor is close 100 percent

m ( no of keys )is approximately N

hashing will be slow

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

how to keep load factor small

A

Keeping the load factor down
 To keep hashing performance up, we need to
keep the load factor a down
 We use rehashing to do so:
 Whenever load factor becomes too large (e.g., >
0.5)
 Create new bucket array approx. double the size
of the old one
 Iterate all elements in the old bucket array and
use put to add them to the new bucket array

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