Hashing Flashcards
What is the general idea of a hash table?
To hash/map an unordered list of entries to a specific position in an array
How does a hash table improve the time of the insert, delete and lookup methods?
Gives them a O(1) worst case complexity. It will always be O(1) if there are no collisions
What is the main disadvantage of a hash table?
that some positions will be null so spaces will arise which makes the methods more complex
What is the table size abbreviated as?
TS which is the number of buckets
What is the hash function?
The operations done to the key to yield it’s respective index value
When does a collision arise
When the hash function gives the same index as another key
How can the problem of collisions be solved?
Have each array point to another data structure(embedded DS)
How do the embedded DS effect the total time complexity?
balanced tree: O(logN)
list: O(N)
What tradeoff exists when choosing a TS?
Amount of space and the number of collisions
What methods can a hash function implement to spread out keys?
multiply some or all values by a constant
What is the problem with multiplying keys by a constant?
array overflow
What is the problem with adding properties together to get the index?
permutations
How is hashing done?
by performing operation(s) on the key to get an index value
What is each element being hashed called?
A bucket. The index corresponding to it is the bucket index
When does the number of items not correspond with the number of buckets?
When collisions occur