mapping adt Flashcards

(9 cards)

1
Q

rehashing with dictionary

A

O(n);
bucket = hash(key) % m;
-# splits keys into m buckets

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

hash(self, key):

A

return key % self._n_buckets

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

rehashing

A

self._n_buckets *= 2;
new_L = [[] for i in range(self,_n_buckets];

for bucket in self._L;
> for entry in bucket:
» new_bucket = self.hash(entry.key);
»new_L[new_bucket].append(entry)

self._L = new_L[:]

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

load factor

A

entries / table size

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

separate chaining

A

collisions are resolved by storing all colliding keys in one slot using an ADT like linked list

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

open addressing / closed hashing

A

collisions are resolved by storing the colliding key in the next best place

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

linear probing

A

solve hash collision by storing the key in the closest following free location

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

quadratic probing

A

search for the i^2 bucket in ith iteration

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

double hashing

A

use a secondary hash function

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