Hash Tables (Module 7) Flashcards

1
Q

What is a data structure that maps keys to values?

A

Hash table

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

What is a hash table also known as?

A

hash map

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

Why are hash tables different from array?

A

they use different types of keys and convert them using hash functions

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

What are the 4 applications of hash tables?

A

1) database indexing
2) caching
3) Symbol tables in compilers
4) networking

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

which hash table application retrieves records using unique keys?

A

database indexing

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

Which hash table application stores and accesses frequently-used data?

A

caching

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

Which hash table application maps variables names in memory locations?

A

symbol tables in compilers

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

Which hash table application stores routing tables and MAC addresses?

A

networking

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

How does the hashing mechanism work?

A

1) Hash function turns key into hash code
2) hash code is used to index into a hash table

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

What 2 things does a hash function’s quality influence in a hash table?

A

1) hash table’s speed
2) hash table’s ability to handle collisions effectively

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

A hash function should preferably compute a hash code in ______ time complexity.

A

O(1)

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

A hash function should distribute hash values ________ across the table

A

evenly

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

A hash function should minimize _________.

A

collisions

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

What does it mean when a hash function experiences a collision?

A

two inputs are mapped to the same index

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

For numerical keys, what is the formula for Modulo hashing?

A

hash(k) = k*modm

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

For numerical keys, what is the formula for Multiplicative hashing?

A

hash(k) = m * ((k * A) mod 1)

17
Q

For numerical keys, what is the formula for Bitwise Operations?

A

hash(k) = (k $ (k&raquo_space; r)) mod m

18
Q

How do you initialize a hashing table?

A

1) use arrays and have each element represent hash key mapping
2) use linked list to store multiple elements that hash to the same index