I believe we could have used two dimentional array from the start, and filter/find using key by matching to x-axis, why do we have to use hash if there is a chance for collision which then will be resolved with two dim array.
I have a silly question, why we do not use an object to save the values? like hashObject = {} hashObject[key] = value let retrievedValue= hashObject[key]
Which collision avoidance method did you use here? I have heard some ways like linear probing and chaining, so which one have you used here? please reply i am confused
Google returned such info: The main advantage of using find() in those cases is that find returns as soon as a match is found, but filter would run through the entire array even if a match is found in the 1 st index position and you don't want to do that for large arrays when all you are concerned about is one match!
hash(key) { let total = 0 for (let i = 0; i < key.length; i++) { total += key.charCode(i) + i } return total ℅ this.size } Maybe this is enough for handling the collision
Thank you sir, the explanation is very easy to understand for me who is still a beginner in learning English 🙏
Hello sir you are really doing a good job as a programmer DSA is very much important thanks for your efforts sir keep it up 👍
Thank you for this pretty course, you are the best instructor, keep going
I believe we could have used two dimentional array from the start, and filter/find using key by matching to x-axis, why do we have to use hash if there is a chance for collision which then will be resolved with two dim array.
brototypians please like!!
bro course complete aayo?
@@AkarshGKumar yes
How is making changes in the "samKeyItem" in the set function allowing us to change this.table[index]
I have a silly question, why we do not use an object to save the values?
like hashObject = {}
hashObject[key] = value
let retrievedValue= hashObject[key]
Thank you!
Which collision avoidance method did you use here?
I have heard some ways like linear probing and chaining, so which one have you used here? please reply i am confused
how is average time complexity constant? since we are using .find..souldnt that be linear O(n)
Vishwas, what about time complexity of splice() as it modifies the existing array...
bucket.push([key, value])
And then
this.table[index] = bucket;
Else overriding the keys will not work as expected.
it's prevent collision when the keys have the same hash result , but when set a new value with the same key it's override.
Could have used array filter() in the remove() instead of using find() and splice().
Google returned such info:
The main advantage of using find() in those cases is that find returns as soon as a match is found, but filter would run through the entire array even if a match is found in the 1 st index position and you don't want to do that for large arrays when all you are concerned about is one match!
hi codevolution you're doing a great job 👍 thank you very much.... tell me do you have React native courses on the channel?
We are looking for React Native Is it hard i know react js very good
but i culdnt arrrange time to start React native yet
hash(key) {
let total = 0
for (let i = 0; i < key.length; i++) {
total += key.charCode(i) + i
}
return total ℅ this.size
}
Maybe this is enough for handling the collision
good thought, there is still chance of collision due to total char sum (even with adding index) in one word can match other word.
@@travelwithme99-0 if you are calculating total it does not matter in which order you will add 1+..+2+..+3+..+4
Hey are you from Maharashtra, India
Really..?