Hashing Flashcards

1
Q

What is hashing?

A
  • Using a Hash function on data to create a ‘unique’ hash
  • This hash determins the position the data is stored at (in the hash table or on a hard disk)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a collision

A

When two peices of data hash to the same index(hash value). This means the second being added wont be able to be stored in this index.

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

Two methods of dealing with collisions?

A
  • Open hashing
  • Closed hashing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is open hashing?

A
  • If a collision happens the inserted data is asigned to the next avalable index.
  • This increases chance of future collisions
  • And increases search time ( to as bad as O(n) as the whole hash table must be checked if a deletion symbol wasnt used.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is closed Hashing

A

Each array position in the Hash table is a linked list.

The inserted data gets added onto the end of the correct linked list.

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

What makes a good hash function?

A
  • Makes use of all information in key
  • Uniformly distributed output across range.
  • Uses fast operations (as its called a lot)
  • maps similar keys to very different hashes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the complexity of accesing ahash table?

A

Constant time, provided no colisiions have happened.

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

Rougly how much space should be in the hash table?

A

1.5 times the amount of data eeding to be hashed and stored. to reduce collisons

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

When is hashing used?

A

Data comms to create a hash of the data being sent, used for checking data is untampered.

Storing data in a way that makes it fast to locate.

In RAM

Look up tables (eg phone book)

Encrypting passwords

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

what is a hash function?

A

A function H, applied to a key k; which generates a hash value ((of range smaller than the domain of values of k)

(A function which computes a record position within a specified range)

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