Hash_maps_in_JavaScript
Hash_maps_in_JavaScript
Data Structures organize and store data in a format that provides for efficient
retrieval.
objects.
arrays.
stacks.
trees.
graphs.
console.log(maps);
//map { 'kabc': 1, 'kdef': 2, 'gei': 3}
Arrays are useful data structure in JavaScript that are zero indexed and used to
store a collection of items within one variable name. Arrays in JavaScript have
several built-in functions, also known as methods, as arrays under the hood
are actually objects as well. However, they differ from hash maps as arrays can
be resized, and the traversal of arrays is slightly different than hash maps. The
time complexity of each is about the same as both are very different than hash
1. Fast data retrieval: Hash maps provide constant-time O(1) complexity for
insertion, deletion, and lookup operations, making them highly efficient for
large datasets.
2. Flexible key-value pairs: They allow you to associate any type of key with any
type of value, providing versatility in data organization.
hash maps have keys and they are necessary for data storage and are
necessary for the hash functions on data retrieval.
hash maps are needed when a unique keys are needed.
hash functions (hash algorithm ) : are calculation to an input key that will
transform it into an address where the data or value will be stored.
Hash functions are also irreversible, and this feature makes hash tables an
asset in cybersecurity. because they are useful in storing passwords and
very sensitive data.
example :
//retreiving
console.log(mapHash.get('Sushi'));
//here its stored using the hash function to add security
console.log(mapHash.size);
Remember that when using the hash function a bucket number is assigned
for the data, and it is a different bucket number for each entry.
Hashing ⇒ is the process in which a key is placed in a hash function and then the
hash function carries out its functionality, thereby creating an index and placing
the keys and their values in a bucket.
hashing is always carried out to avoid collisions, which is where already filled
buckets are used by a hashing function to store additional data from a different
key input.
Hash Functions:
No matter the length of the input the output length is the same.
There is NO Reverse Engineering !!! you cannot go from the hash to the input.
Security of data is important, and hash functions offer another layer of protection
for confidential company data.
Space Complexity : is the total amount of space taken by the algorithm, reliant
upon the input size.
it includes :
auxiliary space.