Data Structures & Algorithms Notes Page
What’s Hashing?
Definition:
- It’s a way to store and find data quickly using a special method called a hash function!
- Kinda like assigning every item a “locker number” based on its name
Hash Functions:
- A hash function takes a key (like a word or number) and turns it into a number called a hash code
- This number decides where to store this data
Simple Visual Example (Concept Only):
int hashCode = key.hashCode(); // Java does this under the hood
The HashMap
Definition:
- A HashMap stores key-value pairs
- Each key is unique and is mapped to exactly one value
Example:
- Kind of like a dictionary:
- Key:
cat
- Value:
small animal