There's no algorithm connecting the position of an element in the array to that element. Searching the array is linear, whereas searching a hash is constant (usually). While hashmaps can be implemented as arrays, arrays are not automatically hashmaps
>whereas searching a hash is constant (usually)
Is this due to because how there is only one way the hash goes into the array without being modified, because of the call to the array function, it's not in an array?
You are asking the wrong question. Here is the questions you should be asking:
What is an array? What is a hash map? This may take a few hours to understand.
Any amount. A hash map is always an array its just an array with rules. Its an array that you index by using a key that you hash and then you divide that result by the length of the array and the remainder is the index that you put the value into. The longer the array the less likely you'll get a hash collision. I am not sure the optimal size, but most are just implemented as btrees so you don't have to allocate as much memory. A hash collision is when two different keys get the same index in the array. The longer the array the less likely it becomes.
You should learn Arrays better before working with Hash Maps based on how you asked this question. Matter of fact, you should learn English better before Programming.
Arrays are a kind of mapping where the keys are elements of a compact range of integers, usually starting at 0 or 1 (depending on language). Implementations usually use some variety of address arithmetic to turn the index into where to get the storage cell that holds the value in question; computers are fantastically good at this.
Hash maps are mappings where the keys are not so restricted, requiring only that they support value equality, and that they have some deterministic function for turning them into an integer (the "hash" function) that has the property that any two values that are equal will have the same hash value computed for them by the hash function. The hash function does not have to be bijective; the length of a string could be used as a (low-quality) hash function for strings. (Internally, hash maps use the hash function to project the key to an array index. And then do trickery to handle collisions, which is why they also require equality. You wanna know how? Look up the implementations.)
It's not strictly required for hash keys to be constant, but it's a really good plan to make them so; modifiable keys can only ever safely equal themselves, and so are a bit useless.
The other major type of mapping found in the wild is an ordered tree, usually a balanced ordered tree (only madmen don't balance that sort of tree). That doesn't require a hash function, but does require an ordering function on the keys instead. The right choice of ordering function isn't always obvious.
As big as my interest in wearing that cute top.
>he doesn't know that hashmaps are implemented as arrays
at least 1
Post in stupid questions general
Or don't because this is really stupid
There's no algorithm connecting the position of an element in the array to that element. Searching the array is linear, whereas searching a hash is constant (usually). While hashmaps can be implemented as arrays, arrays are not automatically hashmaps
>whereas searching a hash is constant (usually)
Is this due to because how there is only one way the hash goes into the array without being modified, because of the call to the array function, it's not in an array?
Idk how to parse what your saying
Just watch a video on havshing almost, it's not complicated
sauce?
That's a man
Not what he asked
he's got some nice breasts. i want to nakadashi him/her
love from kazakhstan
What a cutie, damn
>arrays are not automatically hashmaps
Unless you use PHP
wat
You are asking the wrong question. Here is the questions you should be asking:
What is an array? What is a hash map? This may take a few hours to understand.
Any amount. A hash map is always an array its just an array with rules. Its an array that you index by using a key that you hash and then you divide that result by the length of the array and the remainder is the index that you put the value into. The longer the array the less likely you'll get a hash collision. I am not sure the optimal size, but most are just implemented as btrees so you don't have to allocate as much memory. A hash collision is when two different keys get the same index in the array. The longer the array the less likely it becomes.
it depends on your hash function but if you imagine its free, bigger than 2x the size of a cache line.
what if my hash function is the identity function and i only allow unsigned integers as keys
then you very lucky
You should learn Arrays better before working with Hash Maps based on how you asked this question. Matter of fact, you should learn English better before Programming.
>hash
none for me, thanks.
What's that poop turd doing next to the hash and weed
How old are you?
What's that BBC doing next to the hash and weed
Ara Array
a million
SAUCE
how long is too long for a clit?
An array is a thing, a hashmap is another thing, their definitions do not depend on size.
A map of size 1 with key % 2 is still a map.
An array of size 99 billion is still an array and will segfault if I give it uint64_t(-1)
>will segfault if I give it uint64_t(-1)
incorrect, it's size_t(-1)
WHOMST
a hashmap is an array fricktard
Hash table is a dynamic array where indexes can be any hashable values.
Arrays are a kind of mapping where the keys are elements of a compact range of integers, usually starting at 0 or 1 (depending on language). Implementations usually use some variety of address arithmetic to turn the index into where to get the storage cell that holds the value in question; computers are fantastically good at this.
Hash maps are mappings where the keys are not so restricted, requiring only that they support value equality, and that they have some deterministic function for turning them into an integer (the "hash" function) that has the property that any two values that are equal will have the same hash value computed for them by the hash function. The hash function does not have to be bijective; the length of a string could be used as a (low-quality) hash function for strings. (Internally, hash maps use the hash function to project the key to an array index. And then do trickery to handle collisions, which is why they also require equality. You wanna know how? Look up the implementations.)
It's not strictly required for hash keys to be constant, but it's a really good plan to make them so; modifiable keys can only ever safely equal themselves, and so are a bit useless.
The other major type of mapping found in the wild is an ordered tree, usually a balanced ordered tree (only madmen don't balance that sort of tree). That doesn't require a hash function, but does require an ordering function on the keys instead. The right choice of ordering function isn't always obvious.