Section 7 Chapter 40 - Hash Tables and Dictionaries Flashcards

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

Hash Table

A

A data structure that creates a mapping between keys and values. The location of where an item is stored is determined by the hashing algorithm.

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

Hashing Algorithm

A

A process that determines the location of a value based on its key. For instance taking modulo of the key if it were an integer

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

Folding method

A
A hashing algorithm.  Every pair of numbers is added together and then moduloed.  For insance:
123456
12 + 34 + 56
102 % 10
2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to hash a string

A

The ASCII values of each character are summed together and then a numerical hashing algorithm, for instance modulo, is used to obtain the hash.

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

Process for searching for an item in a hash table

A

1) Apply the hashing algorithm to the key
2) If the item is there then return it
3) If the cell is empty it is not in the table
4) If the item is a different one then move forward to the next cell and repeat from (2)

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

Collision

A

A collision occurs when two key values compute to the same hash

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

Collision resolution

A

Rehashing is used. This is the process of finding an empty slot when a collision has occurred. The most simple rehash is to move forward one cell at a time until an empty one is found

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

Dictionary

A

An abstract data type that is a collection of key-value pairs in which the value is accessed via the associated key

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

How hash tables and dictionaries are related

A

Dictionaries often use hash tables in their implementation in order to provide faster response times for returning values

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