8. Hashing
Hash Array:
pre-storing in a hash array/ freq array to reduce time complexity
-------------------------------------------------------------------------------------------------------------
Character Hashing-
1. without hashing-
2. with hashing-
or
works only if 's' contains a to z works for all characters: A to Z, a to z, others...
------------------------------------------------------------------------------------------------------------- Mapping-
-------------------------------------------------------------------------------------------------------------
NOTE-
1. Stack overflow/ segmentation fault:- MLE
Runtime error- index not available
2. max size(int arr) : 10^6 (inside main), 10^7 (globally)
3. a:97, A:65, total alphabets- 26
4. first priority to choose is unordered map, if TLE occurs then choose ordered map⭐
5. in a map, any data type can be a key (since it is implemented by red black tree)
while it is not so in an unordered map (implemented by hash table)
------------------------------------------------------------------------------------------------------------- COLLISIONS-(u may ignore)
collision is when similar wale goes to same hash place.
Comments
Post a Comment