Hash Tables - Beau teaches JavaScript

  Рет қаралды 93,840

freeCodeCamp.org

freeCodeCamp.org

Күн бұрын

Пікірлер: 40
@lenaggar
@lenaggar 7 жыл бұрын
@Beau thank you for what you do for the community
@arthuretf
@arthuretf 7 жыл бұрын
Shouldn't it be `i < storage[index].length` on line 46?
@BeauCarnes
@BeauCarnes 7 жыл бұрын
Yup! I fixed it in the code that is linked to in the description.
@__abshir
@__abshir 4 жыл бұрын
line 45*
@funkybuddha1598
@funkybuddha1598 3 жыл бұрын
I wasted 2 hours because of that!
@NathanielBabalola
@NathanielBabalola 2 жыл бұрын
On line 30, you're overwriting the previous value that was tied to that key. Is that how it's meant to be ?
@dcts7526
@dcts7526 2 жыл бұрын
was looking for that comment. Since the hashfunction is deterministic, the same key will always result in the same index, hence the value must be by definition the same. Overriding it is unneccessary you are right!
@jhovahngibbs6720
@jhovahngibbs6720 6 жыл бұрын
tux is a penguin, that made me smile
7 жыл бұрын
hey, good video
@chavychaze9366
@chavychaze9366 5 ай бұрын
awful explanation, awful. Why make such an easy topic so hard?
@fatemabohra4277
@fatemabohra4277 6 жыл бұрын
there is no such video except this which explains a simple hash function in javascript in a practical way.
@shayanjavadi
@shayanjavadi 7 жыл бұрын
Really weird mixture of var let and const here. Your storage can be a const since the array location in the memory doesn't change, only the array items do. all the functions should also be consts as well. there's really no point in using var anymore. great video otherwise!
@camillemorell3270
@camillemorell3270 4 жыл бұрын
This is the best video I've watched on Hash Tables
@paschalynukwuani6930
@paschalynukwuani6930 2 жыл бұрын
Beau you are one of the best tutors on the internet.
@goodrowj
@goodrowj 5 жыл бұрын
I think I might be missing something here, wasn't the point of a hastable to have O(1) reads, inserts, and deletes? This is running O(n) blocks for each of those operations. Is there a way to get those down to O(1) in Javascript?
@ernwillburn
@ernwillburn 5 жыл бұрын
Yeah this video is not really correct or O(1)
@dannytran4667
@dannytran4667 5 жыл бұрын
You get constant time by reducing the chance of collision. One simple way to do this is to double your storage size when the load factor gets high (the ratio of items to buckets). When you hit the load factor, double the number of buckets (in this case the storage Limit) and rehash all the items so hopefully they're in their own bucket.
@seyfullah7314
@seyfullah7314 Жыл бұрын
Average time complexity of finding the hash value of any input is already O(n), However, how come the average time complexity of insertion be O(1) ?
@NathanielBabalola
@NathanielBabalola 2 жыл бұрын
The buckets in the hashtable function is 4, but you're using 10 in the hash function ?
@bluemenkranz_2953
@bluemenkranz_2953 2 жыл бұрын
actually iam a beginner but when i reading the code for add function i got confused and i try to fix it with this code instead > this.add = function (key, value) { var index = hash(key, storageLimit); if (storage[index] === undefined) { storage[index] = [key, value]; } else { storage[index].push([key, value]); } }; still work tho
@bruhmoment3731
@bruhmoment3731 2 жыл бұрын
hello Genshin player.
@goodwish1543
@goodwish1543 7 жыл бұрын
Nice explanation. Good work, Beau Carnes ! Line 42, There is a use case in Remove method, that is the key doesn't exist in array. The code logic works. If we may test it separately, it'll be more clear.
@vishalheble
@vishalheble 7 жыл бұрын
Can you explain what do you mean by "When (inserted=== false), then push the key,vales into storage array. But how do we get multiple entries for the same bucket? It means collision right? But how can it happen when you don't find the same key which actually happens in previous case i.e. when the key exists already. Help me.
@sergeypomaraiko4661
@sergeypomaraiko4661 7 жыл бұрын
at line 43 you have deleted array item, but length of array wasn't changed. So line 42 never will be true if we have inserted item once
@facundomartingarciaengel6318
@facundomartingarciaengel6318 3 жыл бұрын
U re the best bro ;) thanks from Argentina!
@OliverMensahDev
@OliverMensahDev 7 жыл бұрын
Good work Sir
@JohnDoe-ji1zv
@JohnDoe-ji1zv 5 жыл бұрын
Is hashtable actually used in a daily programming ? Could you give an example please
@kattenelvis1778
@kattenelvis1778 5 жыл бұрын
No it's only used in leetcode and interview questions.
@RedEyedJedi
@RedEyedJedi 4 жыл бұрын
It is used anytime you want a fast insertion, look up or delete. The data structure you decide to use should always be based on how the data is going to be used. Don't just use an array for everything, although an array can be used for most things, speed is a major factor in developing software.
@dcts7526
@dcts7526 2 жыл бұрын
Good question, would be interested to hear too. We all use hashtables indirectly by using hashmaps, sets or simply objects. But I've never applied a hashtable throughout my developer career so far too...
@sabuein
@sabuein Жыл бұрын
Thank you.
@greendsnow
@greendsnow 2 жыл бұрын
what?
@ChocolateMilkCultLeader
@ChocolateMilkCultLeader 4 жыл бұрын
So well done
@aaronargottelopez3488
@aaronargottelopez3488 3 жыл бұрын
Thanks
@anirvanchandra
@anirvanchandra 7 жыл бұрын
which text editor do you use
@rexromae17
@rexromae17 7 жыл бұрын
that looks like CodePen
@FernandoFleuryGil
@FernandoFleuryGil 7 жыл бұрын
it's a website called codepen
@sifatmoonjerin2479
@sifatmoonjerin2479 4 жыл бұрын
Hey, great content! But I think using splice instead of delete will be a better solution. This throws an error if you remove a chained key and then try to reassign it.
@BrasilEmFatos
@BrasilEmFatos 3 жыл бұрын
hmm, but I think splice gonna remove the slot spaces in our storage, while delete keeps the space associated with that index but with an undefined value.
Linked List - Beau teaches JavaScript
11:57
freeCodeCamp.org
Рет қаралды 99 М.
How to Implement a Hash Table in JavaScript
25:39
Ben Awad
Рет қаралды 104 М.
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
Поветкин заставил себя уважать!
01:00
МИНУС БАЛЛ
Рет қаралды 7 МЛН
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 11 МЛН
Hash Tables and Hash Functions
13:56
Computer Science
Рет қаралды 1,6 МЛН
Binary Search Tree - Beau teaches JavaScript
13:34
freeCodeCamp.org
Рет қаралды 116 М.
Learn Hash Tables in 13 minutes #️⃣
13:26
Bro Code
Рет қаралды 358 М.
The Home Server I've Been Wanting
18:14
Hardware Haven
Рет қаралды 175 М.
Destructuring in ES6 - Beau teaches JavaScript
6:10
freeCodeCamp.org
Рет қаралды 69 М.
Sets (data structure) - Beau teaches JavaScript
10:23
freeCodeCamp.org
Рет қаралды 31 М.
JavaScript Visualized - Closures
11:34
Lydia Hallie
Рет қаралды 41 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Queues & Priority Queues - Beau teaches JavaScript
6:39
freeCodeCamp.org
Рет қаралды 44 М.
Copying Arrays (deep and shallow) - Beau teaches JavaScript
5:56
freeCodeCamp.org
Рет қаралды 45 М.
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН