Hash Tables - CS50 Shorts

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 132

  • @rautermann
    @rautermann 4 роки тому +201

    I just love the pride with which they say "THIS is CS50" at the end of each video. That's really contagious, makes me proud to be a part of it, too!

    • @davidjmalan
      @davidjmalan 4 роки тому +69

      Welcome aboard!

    • @rautermann
      @rautermann 4 роки тому +12

      @@davidjmalan Thank you! I just learned about the genesis of this catchphrase in your freecodecamp interview, haha...
      For everybody interested, listen to it here:
      freecodecamp.libsyn.com/ep-71-harvard-cs50s-david-malan-and-colton-ogden-on-computer-science
      (The part about "THIS is CS50" starts at 01:59:50)

  • @CODE_and_DESIGN
    @CODE_and_DESIGN Рік тому +6

    Thank you, Professor Lloyd, for your amazing explanation of the material in CS50x. I have taken many online courses in the past, but this is the only one that has been so comprehensive and well-explained. I never have to waste time searching for additional information because everything I need is covered in the lectures, sections, and shorts.

  • @Ash-em5pm
    @Ash-em5pm 5 років тому +181

    0:33 vsauce music starts playing in the background

  • @anthonyrosas7838
    @anthonyrosas7838 4 роки тому +93

    I've started watching these videos in 0.75 speed, and I love drunk Doug explaining complex concepts to me! xD

    • @Dall1n
      @Dall1n 4 роки тому +10

      XD 0.5 speed even better!!

    • @LillieLights
      @LillieLights 4 роки тому +5

      I watch them at 1.25 speed to save time XD

    • @jasonbellis9128
      @jasonbellis9128 3 роки тому +3

      @@Dall1n 0.5 speed is gold! hahah Drunk Doug!

    • @AJGthree
      @AJGthree 3 роки тому +7

      I usually watch the lectures at 1.5x. It makes David seem even more energetic than usual lol

    • @BobbyBundlez
      @BobbyBundlez Рік тому

      LOL

  • @xamogxusx
    @xamogxusx 6 років тому +123

    you are the best! keep it up! can't believe such professional lectures are free. Big up Harvard!

    • @aprameyaaithal9071
      @aprameyaaithal9071 3 роки тому

      Agreed 100% 👏

    • @marys.2304
      @marys.2304 3 роки тому

      O0io0o0ii0o0⁰⁸kĺ

    • @marys.2304
      @marys.2304 3 роки тому +1

      @@aprameyaaithal9071 gggĺlllllķ

    • @demaxl732
      @demaxl732 Рік тому +1

      If these lectures are free just imagine the actual lectures in harvard. Man I wished I was a student there😭😭😭

  • @kevinrakhitha6019
    @kevinrakhitha6019 4 роки тому +12

    Loved the Beatles, Simpsons, and Friends references!!

  • @Ceogr
    @Ceogr 12 днів тому

    This guy can explains stuff stupidely well and simple. Thanks a lot Doug!

  • @demaxl732
    @demaxl732 Рік тому +1

    I love harvard university, For some reason almost no one knows how to explaing hash tables in a simple way but this video just clear everything up for me. Thank you Doug!

  • @timurmukhtarov1319
    @timurmukhtarov1319 4 роки тому +7

    This is amazing! The best video explainer of hash tables hands down 🏆

  • @pumpkins922
    @pumpkins922 2 роки тому +1

    I love love love Doug's attitude in these videos

  • @luckydevil1601
    @luckydevil1601 Рік тому +1

    Oh, he linked Phoebe and Joey, so sweeet!😍

  • @thamestrinity
    @thamestrinity 2 роки тому +3

    This is particularly an exceptional video. If only I could follow Doug into more courses.

  • @ElecPrizyy
    @ElecPrizyy 3 роки тому +2

    best teacher ever thank you Doug Lloyd

  • @SumitPilania
    @SumitPilania 2 роки тому +3

    Thank you for explaining it in such a clear and detailed manner. Cheers :)

  • @veroniquev7181
    @veroniquev7181 2 роки тому +1

    John, Paul, Ringo... and that's why I love CS50

  • @yog7558
    @yog7558 4 роки тому

    Thanks CS50, Sending you guys a big hug❤💚

  • @GenZ_01_
    @GenZ_01_ 4 місяці тому

    As David likes to say .
    The complexity escalated quickly .
    Thanks for an awesome explanation!!!

  • @umarmurtala5572
    @umarmurtala5572 Рік тому

    Thank you so much for the illustrative explanation. You just saved my day.

  • @facundoalvarado9
    @facundoalvarado9 4 роки тому +4

    Saved my academic life, thanks!

  • @Shiro_Hairo1
    @Shiro_Hairo1 5 місяців тому

    Thank you, Professor Lloyd!😀

  • @s.spambot9095
    @s.spambot9095 2 роки тому

    Dude! What a masterclass of a video!!!!

  • @luizashabetnick8059
    @luizashabetnick8059 2 місяці тому

    After implementing linear probing on Doug's hash table example now i understand why its not a good example (different char strings can have the same sum so they are given the same hash code)

  • @edmondes489
    @edmondes489 6 років тому +3

    Excellent explanation: you made it clear for me! Thank you.

  • @Jxrrdy
    @Jxrrdy 6 років тому +2

    I love this channel

  • @mollyexten4508
    @mollyexten4508 4 роки тому +14

    What is the standard way to cite the source of my code? Are there rules for this like there are for writing essays in MLA or APA?

  • @abusayeed4551
    @abusayeed4551 2 роки тому

    you really described in a fantastic way....

  • @mon0theist_tv
    @mon0theist_tv 2 роки тому +1

    Why did they switch from "don't write your own hash functions, just find some on the internet" to "you better write your own hash function or else" for pset5 lol

  • @betterhealthtoday644
    @betterhealthtoday644 4 роки тому +7

    "We've chained "Phoebe" in"

  • @DrewCantSkate
    @DrewCantSkate 4 роки тому

    Doug you are a legend, thank you.

  • @GWeekly2904
    @GWeekly2904 2 роки тому

    Thank you so much for the clear explanation

  • @daniilmalygin5347
    @daniilmalygin5347 2 роки тому

    Thank you so much for this.

  • @jadia
    @jadia 6 років тому +10

    Great explanation and that FRIENDS reference though. xD

  • @miaomar3228
    @miaomar3228 2 роки тому +1

    Curious why the hash function Doug wrote isn’t good? It generates different hash codes for similar data and allows you to increase the number of buckets to the extent of memory
    Is it because the number of buckets is not related to the number of elements in the hash structure? If so, how would you know the optimal number of buckets?

    • @ahmetselimerdogan6187
      @ahmetselimerdogan6187 Рік тому

      I think it is bad because it can easily output the same hash code over and over again AB and BA would result in the same hashcode, and also since it is adding up ASCII numbers AAAAA might be equal to ZZZ (the example is symbolic) and then it would result the same hash code as well.

    • @danielmontilla6629
      @danielmontilla6629 Рік тому

      ​@@ahmetselimerdogan6187but if You ask or compare your string to what is actually in the buckets You can diferentiate both, and maybe add some label to like bucket 1.1 and and then if there have the dame ascci value but diferent string You may solv. The things is that You have to iterate and compare all the link list of one bucket.

  • @1mkhlv
    @1mkhlv 5 років тому +21

    Captions aren't not synced with voice. Please fix it

    • @ArturoJReal
      @ArturoJReal 4 роки тому +1

      Hi Ilya, thanks for pointing this out! We've updated the subtitles!

  • @BryceChudomelka
    @BryceChudomelka 4 роки тому

    Awesome. Thanks Doug!

  • @FlowersByIrene
    @FlowersByIrene Рік тому

    I like how he says it's a waste of time to make your own hash function but then this weeks problem set tells you to make your own

  • @溜溜梅-l4z
    @溜溜梅-l4z Рік тому

    Thank you very much!!!

  • @yuchengtsai9888
    @yuchengtsai9888 2 роки тому

    Awesome! Very easy to understand! Thank you!

  • @saturn52
    @saturn52 4 роки тому +1

    Doug = Legend

  • @UnknownUnknown-tx1jc
    @UnknownUnknown-tx1jc 6 років тому +3

    I was thinking about Doug's hash function. He said his hash function is not the best for some reason he was going to get into right now. Is anyone curious about the reasons. looking at the function it add the ascii representation of all the letter in the in the so call string. it then takes the sum of the ascii value of each letter and devide it by size of the array. who could tell me what could go wrong ?? Well suppose when hash jhon and we had a return hash code of 4, suppose we now hash jhon in reverse (nohj) or any sequence of the same characters arrange differently to form another name of the same length , we are going to get the same hash code for these names in other word some collisions. so I guess that's bad but what are the chances right ?? OH by the way thanks for the great lecture Doug. I finally got hash tables

    • @AkayAkbyk
      @AkayAkbyk 5 років тому

      to me it seems like you'd want to use another way of dealing with collisions not because his way would be technically wrong but because as the array grows, you'll eventually run into inefficiencies that negates any performance you gained by using hash tables. for example, what if your array needs to get larger? you'd have to rehash all the values because your "mod" changes. and unless you implement some kind of mechanism to deal with collisions, the max number of elements you can store in your array will be limited to the size of your array (plus one if your default base index is 0.)

  • @matthewlev1342
    @matthewlev1342 6 років тому +1

    Solid video! Thank you

  • @mohammedkhateeb4035
    @mohammedkhateeb4035 2 роки тому

    Legend, Thank you

  • @harshalcharadva4805
    @harshalcharadva4805 3 роки тому

    finally a big confusion was solved. thanks.

  • @bleszieernestinesimbulan3986
    @bleszieernestinesimbulan3986 4 роки тому +4

    I hope they had the source code for this lesson

  • @Olden2610
    @Olden2610 3 роки тому

    Not really sure that is lookup speed is O(1)
    How should we distinguish two different objects with the same hash without additional logic?

  • @uttkarshsachan4063
    @uttkarshsachan4063 3 роки тому +1

    3:00 for future reference!

  • @strateeg32
    @strateeg32 3 роки тому +1

    Rachel and Ross not together in the same list?! How dare you

  • @Axisoft
    @Axisoft 6 років тому +3

    What about in the case that you're trying to add an identical value, e.g. Joey once more? Are duplicates allowed or no?

    • @AkayAkbyk
      @AkayAkbyk 5 років тому +2

      there would have to be something unique about the values, some piece of accompanying information that makes them unique, for example a sort of unique ID. otherwise there is no point to it, unless you're trying to write a program to find out how many times Joey occurs. but if that was the case, you wouldn't be need to use such a hash table, but would rather use one where the KEY is the name and VALUE is a counter that's incremented with every occurrence of Joey.

  • @buitrungthien
    @buitrungthien 4 роки тому

    Can't thank you enough!

  • @SachinGuy
    @SachinGuy Місяць тому

    Now, I can start solving leet codes haha!

  • @db18022
    @db18022 6 років тому

    oh what a relief bro, thanks!

  • @crististaci9364
    @crististaci9364 3 роки тому +1

    thank you daddy loyd

  • @shrutipulstya9
    @shrutipulstya9 4 роки тому

    FINALLY A GOOD VIDEO .

  • @codingwithelhacen990
    @codingwithelhacen990 5 років тому

    great explanation

  • @treddshort
    @treddshort 6 років тому +15

    Hash the citizens of Springfield.

  • @brianlobato1481
    @brianlobato1481 4 роки тому +1

    I'm having some trouble trying to understand how to use the hash tables I can find online. Can someone help me with that? Did any of you had problems with this pset5 and have some good hints for someone who is lost?

  • @zaza2010full
    @zaza2010full 6 років тому

    Quicker and faster, like it. *Thumbs up*

  • @iSgapetti
    @iSgapetti Рік тому

    7:30 "Generally you're probably not going to want to write your own hash functions. It is actually a bit of an art, not a science. And there's a lot that goes into them. The internet, like I said, is full of really good hash functions, and you should use the internet to find hash functions because it's really just kind of an unnecessary waste of time to create your own."
    Why did you lie to us Doug?

  • @Teach-CS
    @Teach-CS 4 роки тому +1

    15:05 Shouldn't that be node hashtable[10], since it arrays are already pointers??

  • @cje8887
    @cje8887 3 роки тому +1

    n o w w e h a s h h o m e r

  • @anagabriele7340
    @anagabriele7340 4 роки тому

    thank you!!!

  • @edwinma6236
    @edwinma6236 4 роки тому

    why is x = 4,(and y =6)? what is stopping x from being 0 or 7?

  • @GOODBOY-vt1cf
    @GOODBOY-vt1cf 4 роки тому

    thank you!

  • @yicai7
    @yicai7 Рік тому

    Awesome

  • @GaganDeepSinghMusic
    @GaganDeepSinghMusic 3 роки тому

    Well explained!

  • @alaakliche9443
    @alaakliche9443 2 роки тому

    is shazem using hashing when searching for music ??

  • @syedmazharalishah8158
    @syedmazharalishah8158 6 років тому +1

    Thanks for teaching.... You are good.. I give you the credit for the work you did ... Plegiarism you said remember!

  • @simonkalu
    @simonkalu 6 років тому +1

    interesting topic. Thanks, teacher. Advanced topic. Could you suggest some real-life applications?

    • @gui1542
      @gui1542 6 років тому +4

      Hash tables are used everywhere. There are entire database system designed around hash tables (Redis). The language python is entirely built around dictionaries, which are essentially hash tables.

    • @danielflores407
      @danielflores407 6 років тому +5

      In Javascript for example all objects are hash tables, you can find Hash Tables under the name of Associative Array

    • @abollden
      @abollden 6 років тому +2

      A real life example could be if you are looking for duplicates in an array. You could loop through each element of the array and create a key value for that element. If the key already exists, then you know you've found a duplicate. The benefit of hash tables is as follows: if you use an ordinary hash object you would have to search each key of the hash object to see if the key already exists, potentially searching through the entire hash object. The benefit of the hash table is the hash function will give you a specific "address" for the key so you can check to see if the key for that specific element exists in one look, instead of having to look at each key in the hash object. In terms of computational complexity, to search a hash object it takes O(n) time but for hash tables it takes O(1).

    • @srijanpaul
      @srijanpaul 4 роки тому

      Many popular language interpreters (Python for example) use them to store your variable names and their respective values. That's how your interprerer knows which variables refers to what.
      They're also used in JS. Every single JavaScript object is actually a hashtable under the hood.

  • @No-sh6vs
    @No-sh6vs 6 років тому +7

    You forgot Chandler Bing!!!!

  • @mr.mirror1213
    @mr.mirror1213 3 роки тому

    Hey but what about cache misses in linked list ?? I thought of using a dynamic array

  • @colonizatorgg5960
    @colonizatorgg5960 5 років тому

    But if hashtable don't have linked list for handle collisions, is hashtable still it?

  • @gabrielpereiramendes3463
    @gabrielpereiramendes3463 5 років тому

    Very Good!

  • @serdashehu
    @serdashehu 4 роки тому

    the beatles ha

  • @SugerNoor1996
    @SugerNoor1996 4 роки тому

    you r great

  • @chiragsharma3688
    @chiragsharma3688 4 роки тому +1

    Hey Dug! you forgot Monica and Chandler lol

  • @CeaserMadrazo
    @CeaserMadrazo 2 роки тому +1

    I feel like such an idiot... No matter how many times I try to understand the Week 5 content, I just can't follow it...

  • @lintz_lin
    @lintz_lin 4 місяці тому

    6:23 "you see what's going on here?"
    er... sorry, no

  • @abollden
    @abollden 6 років тому

    Can somebody recommend a great hash function for javascript?

  • @fabianandrespinedasalazar297
    @fabianandrespinedasalazar297 4 роки тому +1

    Captions are not sync :/

  • @itspurelypassionate
    @itspurelypassionate 4 роки тому +1

    Aha! Friends 😁 Chandler and Monica are missing😅

  • @adilismail3593
    @adilismail3593 5 років тому

    Wat r buckets in hash tables?

  • @baatar
    @baatar 5 років тому +1

    Why are we getting collisions? Shouldn't a good hash function barely have any?

    • @MRender32
      @MRender32 5 років тому +2

      It's not something that can be completely avoided, so there needs to be protocol.

    • @AwsmLx
      @AwsmLx 5 років тому

      depends on what you are trying to achieve

    • @sengelhard2982
      @sengelhard2982 5 років тому

      Collisions are always possible. The hash value is inherently smaller than the value being hashed, so considering all possibilities, there have to be some values that result in the same hash.

  • @BobbyBundlez
    @BobbyBundlez Рік тому

    unreal.

  • @menottitrades
    @menottitrades 4 роки тому +1

    where can i find hash functions already created?

    • @srijanpaul
      @srijanpaul 4 роки тому +2

      Google should yield some results. They aren't uncommon at all.

  • @kattodoggo3868
    @kattodoggo3868 4 роки тому

    Geez this speller is killing me

  • @nezzzumi1
    @nezzzumi1 4 роки тому

    (y)

  • @GaneshPatil-fs6cn
    @GaneshPatil-fs6cn 4 роки тому

    1000 Likes

  • @JigarPatel28
    @JigarPatel28 6 років тому

    I don't think you'd be allowed to look up hash functions online during interviews sir

  • @nowinandroid
    @nowinandroid 6 років тому

    or we can just use HashTable classes and leverage OOP... without even worrying about it :D

  • @porobignardi8369
    @porobignardi8369 6 місяців тому

    Awesome