Hash Tables
HashMap
Implements map interface, internal storage container for keys is a Hashtable
How do hashing methods work?
Input a large piece of data and reduce it to a smaller piece (usually an integer). Input does not need to be an integer
What is the time complexity of hash table operations?
O(N)
Hashing by Folding
Partition key into several parts, and combining int values of those parts
TreeSet
Set whose container is a Red Black Tree
Hashing by Mapping
Used to convert int values or things that can be easily converted to ints (like chars)
Shifting
Using bitwise operators to shift values in order to create the hash
HashSet
data is stored in a table with an associated hash code. Has code is used as an index. Contain NO duplicates, elements kept in order.
Load Factor
in a hash table, the fraction of the table's capacity that is filled. Normally resize when this reaches .75
How does a hash table assign an index to a value?
value's hashcode is % by the length of array. Array should optimally be a prime number (more even distribution).
Open Addressing with linear probing
when a collision occurs the calculated hash index is incremented by one.