8. hashing
Hash Array:
pre-storing in a hash array/ freq array to reduce time complexity
------------------------------------------------------------------------------------------------------------ Character hashing-
1. without hashing-2. with hashing-
------------------------------------------------------------------------------------------------------------- Mapping-
-------------------------------------------------------------------------------------------------------------
NOTE-
1. Stack overflow/ segmentation fault- more memory used.
runtime error- accessing index not available.
2. maxsize(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 map
unordered map- O(1), worst case: O(N)
ordered map- O(logN)
5. in a map, any data type can be a key while it is not so in an unordered map
------------------------------------------------------------------------------------------------------------- COLLISIONS-(u may ignore)
collision is when similar wale goes to same hash place.
Comments
Post a Comment