Hash Table Flashcards

1
Q

What is Robin Hood Hash Table main goal?

A

To scatter the biggest distance elements

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

What is double hash table?

A

using two hash functions

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

What is linear hash table?

A

inserting elements in linear sequence; when an index is taken, you add one to it and going again

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

What is open-addressing?

A

When you directly add to the table; chaining is the opposite of that, because in chaining hash table you insert elements in the same index, but they are chained together

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

Which implementation is the fastest in hash tables?
chaining
linear
quadric
double
robin hood
cuckoo

A

Double hash table can be named as the fastest, but they all are very close, especially linear, quadric, double.
Robin Hood supposes to be good when we have big data demand.

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

What is Cuckoo hash table?

A

It is a hash table structure which uses two tables, when in the first one index is occupied then it searches for available place in the second table.
Important in this implementation is private function rehash, that rehashes both tables when they are nearly full ( size >= capacity * 0.7).
It is easy to manage.

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

What is the main reason to use hashing tables?

A

Search time is O(1), like is also amortized inserting and removing

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

What is the basic hash?

A

key modulo capacity

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

How you will prevent going beyond capacity in a second hash function?

A

1 + (key % (capacity - 1) → where the key should be the index from first hash

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

How would you handle the resize/rehash method?

A

Firstly, I will implement it private. It should have a pointer to old table and old capacity. Next step is to make new table with different capacity, fill it with -1 or NULL it depends. You have to traverse elements from old table to new table with increased or decreased capacity.

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