-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHash_Tables_Notes.txt
29 lines (21 loc) · 1.7 KB
/
Hash_Tables_Notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
HASH TABLE NOTES
Concept: Hash Table in this topic is a hash map which is there is an index that be the key of a table or map that can be used to access the data in the hash table
Mapping the key in hash table called "Hashing"
There are many ways to mapping the key in the hash table:
- Mid Square: If we got an index or a key we can square it and then take the middle key.
- Division: This is the most common hashing concept in the hash table which is to divide the key using the modulus operator
- Folding Methods: Partition the key into several parts and then sums up the parts together and then divide the sum using modulus operator
- Digit Extraction: We just take a predefined digit of the given number
- Rotating Hash: Use any method mention above and then just rotate the key
Collision:
Collision is a term, when the hash table size is full or there is a key that want to be store in the hash table, but there is already exist the same key before it
The top most collision handling known in hash table are:
- Linear Probing
--> When there is a key that want to be store in the hash table, but there is already exist the same key before it, then we will iterate through all the index of
the hash table size that is still empty.
When the index is empty then we store the key there, but if we come back to the first key, then the hash table slot is full.
- Chaining
--> Chaining is the collision handling that if there is a key that want to be store in the hash table, but there is already exist the same key before it,
then that key will make a Linked List, so the key still store in the same index,
but in can be somewhere at the linked list with an index of the key.
I think that's all basic concept of hash table, thankss :)