Hashing Flashcards
What is hashing?
- 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)
What is a collision
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.
Two methods of dealing with collisions?
- Open hashing
- Closed hashing
What is open hashing?
- 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.)
What is closed Hashing
Each array position in the Hash table is a linked list.
The inserted data gets added onto the end of the correct linked list.
What makes a good hash function?
- 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
What is the complexity of accesing ahash table?
Constant time, provided no colisiions have happened.
Rougly how much space should be in the hash table?
1.5 times the amount of data eeding to be hashed and stored. to reduce collisons
When is hashing used?
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
what is a hash function?
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)