Hashing - Double Hashing

Поделиться
HTML-код
  • Опубликовано: 9 фев 2025
  • Video 54 of a series explaining the basic concepts of Data Structures and Algorithms.
    This video explains the concept of Double Hashing.
    This video is meant for educational purposes only.

Комментарии • 143

  • @pencilcat8034
    @pencilcat8034 2 года назад +22

    This channel is a godsend for all who are taking the course Data Structures and Algorithms (and similar) and suffer, like so many others, from lecturers who can't teach. Myself included. I would fail and drop out if videos like these didn't exist.

  • @POwens
    @POwens 3 года назад +90

    This saved me from failing out of my intro to data structures course (during COVID). Life saver.

    • @BhargavPuri-ki7hm
      @BhargavPuri-ki7hm Год назад +1

      Why madam takes 7 there

    • @Ahmet-dr1rq
      @Ahmet-dr1rq 9 месяцев назад +1

      @@BhargavPuri-ki7hm I think question gives us

  • @TheVk30
    @TheVk30 3 года назад +4

    literally the most underrated hashing legend
    thank you for saving me

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

    Short and crisp explanation with example. Saved my lots of time. Thanks a lot

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

    Thank the gods this video exist!

  • @رند-س5ح
    @رند-س5ح Год назад

    Thank you so much this saved me from today's discussion of data structures

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

    Τhank you sooooooo much ... I was looking for this for 6 hours and it was a five min solution... hate my life -_-
    BUT YOU ARE GREAT:)

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

    I love the way you break down the concepts!! Thank you so much for sharing !

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

    Your voice is amazing ,it made fall to sleep .
    thank u ,u saved my life ,keep the good work

  • @heyyoga7515
    @heyyoga7515 4 года назад +9

    You are an excellent teacher! Did great on my quiz because of this video ❤️

  • @FreddyJettyJohnson
    @FreddyJettyJohnson 5 лет назад +10

    Thank you so much, you're doing a great job ❤️

  • @DuyNguyen-wx5oj
    @DuyNguyen-wx5oj 4 года назад +2

    great explanation and neat handwriting!

  • @МартаДяків-т2л
    @МартаДяків-т2л 3 года назад +1

    Thank you so much for your videos! You are just the best!

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

    A simple example was taken. Hope you expand to a bigger example with multiple collisions.

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

    Very nice
    Clearly understand
    Your voice is awesome ❤️❤️

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

    WHAT A LIFESAVER, THANKS AND LOVE YOU SO MUCH, HOPE YOU HAVE A NICE DAY

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

    You are a fantastic explainer. Much love from Texas :) and pray I pass this exam!

  • @hasan_shans
    @hasan_shans 10 месяцев назад

    Very nice courses! Thank you madam!

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

    this is life saver. thank you

  • @eeni14
    @eeni14 4 года назад +5

    Thank you so much! The explanation is really clear

  • @Albatross-vn7lq
    @Albatross-vn7lq Год назад

    that was too simple..Thank u mam

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

    Great job explaining!

  • @abdullahabod6100
    @abdullahabod6100 4 года назад +10

    18mod7 =4 k= 4 , hash2 7-4=3 and so on for other numbers

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

      Pro trick : watch movies at Flixzone. Been using them for watching a lot of movies during the lockdown.

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

      @Christian Oliver definitely, I've been using flixzone} for years myself =)

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

      How to calculate mod..18%7 is 1.26 naa ❓

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

      Reply plz

    • @saharshamagar5059
      @saharshamagar5059 2 месяца назад

      @@Mammajiprincess 18/7 --> remainder = 4 so 18%7=4.

  • @nqnqnq
    @nqnqnq Год назад +6

    there's an issue with this, you can get out of bounds.
    let's try to hash key 12, supposing index 12 is already occupied.
    hash1(12) = 12, hash2(12) = 2
    you'd need to add key 12 at position 14, which doesn't exist.
    fix: position should be given by (hash1(key) + j * hash2(key)) mod size.

    • @kevinkingsly
      @kevinkingsly Год назад +1

      This is the correct method

    • @grinder69
      @grinder69 28 дней назад

      πολύυυυυυ μάγκας respect

  • @yousafraza7747
    @yousafraza7747 4 года назад +5

    Saved my day

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

    Beautifully explained

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

    amazing explanation, thank you

  • @Anonymousgirl620
    @Anonymousgirl620 2 месяца назад

    Thank you sister helped a lot

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

    Great explanation, thank you very much!

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

    Nice explaination

  • @木林海风
    @木林海风 2 года назад

    Beautiful handwriting and cute voice ♥

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

    Very nice.continue like this

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

    Wowee great vid, helped a lot thx so muhc tee hee

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

    Really helpful!! very clear

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

    Amazing explanation, thank you so much

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

    Short and concise :) please make more videos like this 👍

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

    Short and sweet

  • @1muharremyilmaz
    @1muharremyilmaz 2 года назад

    Thanks, From TURKEY

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

    wow, me encanta que excelente explicación, muchas gracias.

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

    thank u friend.. just for this video i can clear my concept

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

    very much helpful thank you

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

    mam why don't you upload new videos .your videos are far more better then university professors !

  • @makeitmakesense-e3x
    @makeitmakesense-e3x 3 месяца назад

    It would have been nice if you showed how you got the hash 2 values

  • @Cxdr-1
    @Cxdr-1 Месяц назад

    Great !!

  • @aswinbaiju5628
    @aswinbaiju5628 4 года назад +9

    And what happens if we get a larger value than our index limit?

    • @qb415
      @qb415 8 месяцев назад +1

      Normally you would do (hash1 + i + hash2) modulo array.length. This way the value can't exceed the index limit.

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

    love your hand writing :D

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

    Excellent job madam 🤩🤩🤩🤩🤩

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

    Thanks for the forecast! I need some advice: My OKX wallet holds some USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). How can I transfer them to Binance?

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

    I think the first thing you should say is that double hashing only works for a prime length array.
    The second thing you should fix is:
    I think the formula should not d be hash(k) + jhash2(k), the reason being that I tried it using a while loop in java and it enters an infinite loop . By your approach if the j is zero then the code would keep on repeating itself(do keep in mind that the second function cannot have the value of 0 in double hashing). So it should always start with hash(k) + hash2(k). So it should look like this hash(k)=hash(k)+hash2(k). This way we would always reach the intended way purpose of double hashing which is to increment hash(k) with the value of hash2(k).
    Like many beginners, I think those 2 points would make it easier for us to grasp and comprehend the material. Thank you, otherwise great content and delivery

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

      I think that starting with j = 0 is fine, there doesn't seem to be any reason why you'd need to start with j = 1. Also, double hashing can work on non-prime length tables, if the hash2(k) always outputs a number that is not a factor of the size of the table.

  • @ort.school
    @ort.school 9 месяцев назад

    cool, thanks

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

    y u have taking in hash2 (K)=7- kmod7??

  • @faheemahmadofficial7701
    @faheemahmadofficial7701 2 года назад +2

    18's key hash 2 is 4 not 3???

    • @anshgoel6661
      @anshgoel6661 4 месяца назад

      second hash function is k(mod)7 so putting the values in (7-k(mod)7) it comes out to be 3

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

    THank you very much

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

    Thank you sooo much ❤

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

    Maam , when addition --- h1(k)+ j*h2(k) ,,,, greater than 13 , then what to do?

  • @bouboudubinks6959
    @bouboudubinks6959 9 месяцев назад

    amazing

  • @valeriosilvestro7067
    @valeriosilvestro7067 5 лет назад +5

    why 7?? is it an upper bound of 13/2?

  • @ΠαναγιώτηςΧατζηδαυιτίδης

    thank you kind woman

  • @tahofu2618
    @tahofu2618 4 года назад +2

    what do you mean ... 5 + 0 in to 3, then 2 + 0 in to 1? I thought it was supposed to be hash1 + hash2 ??

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

    for this example if 44 hash 1 was 5 and hash 2 was 6. Would we go in position 6? or would we do location of 5+(6*2)mod 13?

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

    Thanks tomorrow I'll have a ds exam

  • @tafveezahmad9692
    @tafveezahmad9692 3 года назад +8

    ERROR IS THERE (hash1(k) +j*hash2(k))modN will be there you have missed modN

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

    Thanks! But how do SEARCH (not insertion) works? For example, how to find 44, if 18(at index 5) was removed an is EMPTY?

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

    perfect teacher :o))

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

    It can happen that hash1(k) + j * hash2(k) > 13
    I think its possible, despite that 7 and 13 are prime. In your example you had "Lucky numbers" :D
    Otherwise you end up with index out of bounds.

    • @StoicLife-7
      @StoicLife-7 2 года назад

      doesn't matter if index is out of bounds

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

      @@StoicLife-7 so if it becomes out of bounds then what happens?

    • @nqnqnq
      @nqnqnq Год назад +1

      @@StoicLife-7 it does

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

    thank you very much for your videos. I have a question , what will we do if the collision occur at the final key when using linear probing and quadratic probing ?

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

    thanks you so much

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

    what would happen if sum of two hashes is more than the table size?

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

    maam,
    are you doing MS in AI ?

  • @Guru-UPSC
    @Guru-UPSC 5 лет назад +4

    Why u chose hash2 a particular function. Plz, elaborate the reason for choosing that function. Thanks

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

    Where did you get the 7?

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

    nice!!!!

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

    I don't know how you manufactured the 7 in the first four lines and you didn't explain that. Had to use other resources to figure that out.

  • @kantipudiavinash5743
    @kantipudiavinash5743 2 месяца назад

    Nice voice❤

  • @divyaaskihal2194
    @divyaaskihal2194 5 лет назад +6

    why did u take 7 while calculating v alue of h2?

    • @ashishthanga13
      @ashishthanga13 5 лет назад +3

      r-k mod r is the formula and r should be a prime number less than the size of hash table

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

      Its given in question and changes according to question.

  • @gayallaksara5256
    @gayallaksara5256 5 лет назад +2

    Why didn't you modularized the double hashing function by the table size

    • @niazahmad7823
      @niazahmad7823 5 лет назад +1

      Yeah she made that mistake she has to take modulus of the whole h1 plus h2

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

    Thank You

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

    dought free lecture :)

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

    Ye hash 1 nd hash 2 kha se aaya

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

    How can u take that mod 13. If they given we taken.... right...and for hash 2 also how can u randomly take 7 and for the mod also take 7

  • @BhargavPuri-ki7hm
    @BhargavPuri-ki7hm Год назад +1

    Why madam takes 7 there

  • @jayprakashjaiswaldeptofcom1250

    really ,u dont think its important to tell hwo to take second hash function ?

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

    Are you from CMU?

  • @dipanshunautiyal4234
    @dipanshunautiyal4234 5 лет назад +2

    Vo 11-kmode11 ku nhi hua?

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

    Anyone here know what m in this statement could be?
    H2(k) = 1 + (k mod (m - 1)
    I get that it's the hash2 taking the key as input, but what would m represent here? A value incrementing if the spot it taken perhaps?

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

      The m represents the size of the array so if you have got an array of [1, 2, 3, 4, 5, 6] then the m is 6. AAU gang here to save you (skal selv op i ALG)

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

      @@J2KJonas King, gir en øl i gaden.

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

    😇😇😇😇

  • @SirSimon-zg2rm
    @SirSimon-zg2rm 5 лет назад

    Thanks!!!!

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

    I lub u😻

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

    How to get hash1 and hash2 values

  • @mohammedafzal5720
    @mohammedafzal5720 5 лет назад +1

    How did you calculate H1 and H2?

    • @AshutoshSingh-qj1gm
      @AshutoshSingh-qj1gm 5 лет назад

      taking mod values, like we do for other hashing functions

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

      @@AshutoshSingh-qj1gm not exactly there's sth about prime numbers for H2.

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

      @@fisayoojo9331 it has to be of q - (k mod q) where q is smaller or equal the size of the array

  •  3 года назад

    saolasın hintli bacı

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

    11 mod 7 is 4

  • @sinto4105
    @sinto4105 5 лет назад +1

    you have taken easy example

    • @sinto4105
      @sinto4105 5 лет назад +2

      take some complex example

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

    I want extendable hashing

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

    HELLO im from poland, im young programmer, im have algoritmos kolokwium, thx for help.

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

    The hash 2 value of key 44 is 1 not 5.

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

    h2(K) i didn't understand

  • @sameerthakur851
    @sameerthakur851 2 месяца назад

    mam wiTh face cam pdao

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

    eyy ooru madam meddhi
    mee number pettandi please

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

    Explain me the calculation of
    " hash2 "