Hash Tables - CS50 Shorts

Поделиться
HTML-код
  • Опубликовано: 25 дек 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 года назад +70

      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)

  • @Ash-em5pm
    @Ash-em5pm 5 лет назад +182

    0:33 vsauce music starts playing in the background

  • @anthonyrosas7838
    @anthonyrosas7838 4 года назад +95

    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 2 года назад

      LOL

  • @Ceogr
    @Ceogr Месяц назад +2

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

  • @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.

  • @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!!

  • @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!

  • @pumpkins922
    @pumpkins922 2 года назад +1

    I love love love Doug's attitude in these videos

  • @timurmukhtarov1319
    @timurmukhtarov1319 4 года назад +7

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

  • @veroniquev7181
    @veroniquev7181 2 года назад +1

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

  • @GenZ_01_
    @GenZ_01_ 5 месяцев назад

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

  • @ElecPrizyy
    @ElecPrizyy 3 года назад +2

    best teacher ever thank you Doug Lloyd

  • @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.

  • @SumitPilania
    @SumitPilania 2 года назад +3

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

  • @yog7558
    @yog7558 4 года назад

    Thanks CS50, Sending you guys a big hug❤💚

  • @facundoalvarado9
    @facundoalvarado9 4 года назад +4

    Saved my academic life, thanks!

  • @umarmurtala5572
    @umarmurtala5572 2 года назад

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

  • @Shiroglen
    @Shiroglen 6 месяцев назад

    Thank you, Professor Lloyd!😀

  • @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?

  • @jadia
    @jadia 7 лет назад +10

    Great explanation and that FRIENDS reference though. xD

  • @s.spambot9095
    @s.spambot9095 2 года назад

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

  • @Jxrrdy
    @Jxrrdy 7 лет назад +2

    I love this channel

  • @edmondes489
    @edmondes489 6 лет назад +3

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

  • @abusayeed4551
    @abusayeed4551 2 года назад

    you really described in a fantastic way....

  • @luizashabetnick8059
    @luizashabetnick8059 3 месяца назад

    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)

  • @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"

  • @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

  • @DrewCantSkate
    @DrewCantSkate 4 года назад

    Doug you are a legend, thank you.

  • @saturn52
    @saturn52 4 года назад +1

    Doug = Legend

  • @daniilmalygin5347
    @daniilmalygin5347 2 года назад

    Thank you so much for this.

  • @GWeekly2904
    @GWeekly2904 2 года назад

    Thank you so much for the clear explanation

  • @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.

  • @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?

  • @harshalcharadva4805
    @harshalcharadva4805 4 года назад

    finally a big confusion was solved. thanks.

  • @yuchengtsai9888
    @yuchengtsai9888 2 года назад

    Awesome! Very easy to understand! Thank you!

  • @SachinGuy
    @SachinGuy Месяц назад

    Now, I can start solving leet codes haha!

  • @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!

  • @mohammedkhateeb4035
    @mohammedkhateeb4035 2 года назад

    Legend, Thank you

  • @zaza2010full
    @zaza2010full 6 лет назад

    Quicker and faster, like it. *Thumbs up*

  • @matthewlev1342
    @matthewlev1342 6 лет назад +1

    Solid video! Thank you

  • @GaganDeepSinghMusic
    @GaganDeepSinghMusic 3 года назад

    Well explained!

  • @bleszieernestinesimbulan3986
    @bleszieernestinesimbulan3986 4 года назад +4

    I hope they had the source code for this lesson

  • @crististaci9364
    @crististaci9364 3 года назад +1

    thank you daddy loyd

  • @溜溜梅-l4z
    @溜溜梅-l4z Год назад

    Thank you very much!!!

  • @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?

  • @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.

  • @db18022
    @db18022 6 лет назад

    oh what a relief bro, thanks!

  • @Teach-CS
    @Teach-CS 4 года назад +1

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

  • @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.)

  • @shrutipulstya9
    @shrutipulstya9 4 года назад

    FINALLY A GOOD VIDEO .

  • @buitrungthien
    @buitrungthien 4 года назад

    Can't thank you enough!

  • @alaakliche9443
    @alaakliche9443 2 года назад

    is shazem using hashing when searching for music ??

  • @codingwithelhacen990
    @codingwithelhacen990 5 лет назад

    great explanation

  • @treddshort
    @treddshort 6 лет назад +15

    Hash the citizens of Springfield.

  • @uttkarshsachan4063
    @uttkarshsachan4063 3 года назад +1

    3:00 for future reference!

  • @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?

  • @edwinma6236
    @edwinma6236 4 года назад

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

  • @cje8887
    @cje8887 3 года назад +1

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

  • @strateeg32
    @strateeg32 3 года назад +1

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

  • @syedmazharalishah8158
    @syedmazharalishah8158 6 лет назад +1

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

  • @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?

  • @anagabriele7340
    @anagabriele7340 4 года назад

    thank you!!!

  • @No-sh6vs
    @No-sh6vs 6 лет назад +7

    You forgot Chandler Bing!!!!

  • @GOODBOY-vt1cf
    @GOODBOY-vt1cf 4 года назад

    thank you!

  • @chiragsharma3688
    @chiragsharma3688 4 года назад +1

    Hey Dug! you forgot Monica and Chandler lol

  • @yicai7
    @yicai7 Год назад

    Awesome

  • @simonkalu
    @simonkalu 7 лет назад +1

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

    • @gui1542
      @gui1542 7 лет назад +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 7 лет назад +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.

  • @abollden
    @abollden 6 лет назад

    Can somebody recommend a great hash function for javascript?

  • @adilismail3593
    @adilismail3593 5 лет назад

    Wat r buckets in hash tables?

  • @lintz_lin
    @lintz_lin 5 месяцев назад

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

  • @gabrielpereiramendes3463
    @gabrielpereiramendes3463 5 лет назад

    Very Good!

  • @itspurelypassionate
    @itspurelypassionate 4 года назад +1

    Aha! Friends 😁 Chandler and Monica are missing😅

  • @SugerNoor1996
    @SugerNoor1996 4 года назад

    you r great

  • @fabianandrespinedasalazar297
    @fabianandrespinedasalazar297 4 года назад +1

    Captions are not sync :/

  • @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...

  • @serdashehu
    @serdashehu 4 года назад

    the beatles ha

  • @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.

  • @BobbyBundlez
    @BobbyBundlez 2 года назад

    unreal.

  • @baatar
    @baatar 6 лет назад +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.

  • @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 7 лет назад

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

  • @porobignardi8369
    @porobignardi8369 7 месяцев назад

    Awesome