Hash Tables Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Purpose

A

Way of storing data to be retrieved with a constant time complexity of O(1).

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

Purpose

A

Way of storing data to be retrieved with a constant time complexity of O(1).

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

Hashing algorithm definition

A

Takes an input and returns a hash.

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

What is a hash?

A

Unique to its input and cannot be reversed to retrieve the input value.

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

Hashing algorithm example

A

Value

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

What is returned for each input?

A

The same hash is always returned for each input.

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

What do hash tables store?

A

A value alongside a key.

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

What happens when a value is inserted into a hash table?

A

The value is hashed to produce a key. The value is then stored in the table alongside its key.

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

What happens when a value is to be looked up in a hash table?

A

It is first hashed - after the hash is calculated, the position in the table corresponding to that hash is queried and the desired information is located.

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

What is a collision?

A

When different inputs produce the same hash.

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

What can a collision lead to?

A

Data being overwritten in a hash table in a poorly designed system.

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

How do well designed hash tables get around collisions?

A

Rehashing (finding an available position according to an agreed position).

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

What is rehashing?

A

finding an available position according to an agreed position.

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

What is an example of a rehashing technique?

A

Keep moving to the next position until an available one is found.

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

Hashing algorithm definition

A

Takes an input and returns a hash.

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

What is a hash?

A

Unique to its input and cannot be reversed to retrieve the input value.

17
Q

Hashing algorithm example

A

Value

18
Q

What is returned for each input?

A

The same hash is always returned for each input.

19
Q

What do hash tables store?

A

A value alongside a key.

20
Q

What happens when a value is inserted into a hash table?

A

The value is hashed to produce a key. The value is then stored in the table alongside its key.

21
Q

What happens when a value is to be looked up in a hash table?

A

It is first hashed - after the hash is calculated, the position in the table corresponding to that hash is queried and the desired information is located.

22
Q

What is a collision?

A

When different inputs produce the same hash.

23
Q

What can a collision lead to?

A

Data being overwritten in a hash table in a poorly designed system.

24
Q

How do well designed hash tables get around collisions?

A

Rehashing (finding an available position according to an agreed position).

25
Q

What is rehashing?

A

finding an available position according to an agreed position.

26
Q

What is an example of a rehashing technique?

A

Keep moving to the next position until an available one is found.