Good Hash Function - (Even Distribution | Easy Computation) Hashing

Поделиться
HTML-код
  • Опубликовано: 24 июл 2024
  • This video lecture is produced by S. Saurabh. He is B.Tech from IIT and MS from USA.
    In this lecture you will learn about how to design good hash function.
    What are the qualities of good hash function
    It should be evenly distributed
    It should be easy to compute
    To study interview questions on Linked List watch • Programming Interviews...
    To prepare for programming Interview Questions on Binary Trees
    • Programming Interviews...
    To study programming Interview questions on Stack, Queues, Arrays visit
    • Programming Interviews...
    To watch all Programming Interview Questions visit
    • Programming Interviews...
    To learn about Pointers in C visit
    • Pointers in C (All you...
    To learn C programming from IITian S.Saurabh visit
    • C Programming Tutorial

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

  • @mayurgupta1841
    @mayurgupta1841 9 лет назад +13

    Your explanation for second hash function u used i.e sigma(key[i]).27^imod1000 is not justified

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

    Thank you so much it was really helpful to study!!

  • @dilipjain9581
    @dilipjain9581 8 лет назад

    great explanation!
    Thanks!

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

    it says easy but i don't understand anything still better explanation than my teacher

  • @shpsi
    @shpsi 8 лет назад +1

    best vid ever!

  • @3757xyz
    @3757xyz 9 лет назад

    HI Saurabh, Thanks for the excellent work!!
    I have a query on how you arrived at the numbers 27 in 2nd case and 32 in 3rd case.
    I know we prefer prime numbers to have maximum possible distribution but would like to hear your thoughts on why 27 and 32?
    Thanks!

    • @diksha5746
      @diksha5746 8 лет назад

      +Sudheer Kumar Puzzled at how he came up with these numbers too. Would appreciate some explanation

    • @SandeepDivekar
      @SandeepDivekar 8 лет назад

      +Diksha +saurabhschool can you tell us how you arrived at these numbers?

    • @pinakdas163
      @pinakdas163 8 лет назад

      +Sudheer Kumar 32 here probably means the word size of a machine in bits

  • @abhijeetadhikary4517
    @abhijeetadhikary4517 7 лет назад

    what is the value of "key" inside key[key-size-i]*32^i

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

    Thanks a lot!

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

    where did you get 10007? it's so random

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

    Please be clear and specific with your choice of words

  • @zsoltszarka4153
    @zsoltszarka4153 8 лет назад

    Can you calculate the original key from its hash value? Good lecture by the way.

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

      no obv not, thats the definition of a hashfunction. altough in some cases its possible but for that youd need cipher block chaining and a padding oracle....

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

      ah nvm 7 years ago lol

  • @sahilrally4491
    @sahilrally4491 10 лет назад +2

    Why we say hash function takes o(1) time in searching any Key, in my opinion it should be o(Lambda) where lambda is a load factor ?

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

      yes, O(1) is said only when we assume there is no collision, other wise it will be O(lambda)

    • @sahilrally4491
      @sahilrally4491 10 лет назад

      saurabhschool
      Hello Saurabh, i have doubt, Let us suppose that there is NO Collision at all , even then how could the time is o(1) , is it not o(n) because Algo has to compare keys with all the keys in the cells in order to get which Key matched correctly.
      O(1) Means constant time, but as you increase the number of elements to put in the HastTable, you have to increase the size of the table also, which means it is linearly related to the input size and hence o(n).

    • @alexanderrosenbergjohansen9488
      @alexanderrosenbergjohansen9488 9 лет назад +6

      Sahil Rally The hashtables uses a data structure called "Arrays", Arrays uses a prefixed amount of space in memory(as opposed to Lists), thus through 'direct access'(a function in memory) you are able to access a given and predefined position in memory for a given array index in O(1) time. Hope that made it more clear :)

    • @sahilrally4491
      @sahilrally4491 9 лет назад

      Gunnar Nielsen Thanks !!! Appreciate!!!

  • @sureshguguloth9161
    @sureshguguloth9161 8 лет назад

    I is very good...........

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

    Yaar kitni baar 'Ok' bolega. Aisa lag raha hai okay's ke beech mein thoda bohot padha dia

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

    You say that mod 10 is not a good hashfunct. because it hasn't a even distribution for the numbers 10,20,1000,10000... and than you say mod 7 is better because the distribution is even for 10,20..... ?! But if you use 7,14,21... mod 7 is very bad too!! So I didn't understand what is better with mod 7 then 10

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

      He means with regard to this data sample, using mod 7 is a better choice than mod 10. That's what's about choosing an appropriate hash function which meets the need of the current data

  • @jasiewcaleniechwale3461
    @jasiewcaleniechwale3461 8 лет назад

    byłem w manche# ze 3 razy angielski słabo umiem ale lektor jak chuj pakol!

  • @qwe123727
    @qwe123727 9 лет назад

    Are you seriously an IITian? I doubt

  • @MadForCs16
    @MadForCs16 9 лет назад +1

    quite good videos ..knowledge is also wide f urself but plzzz correct ur accent ..thats too muchh irritating

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

      if accent bothers u .. u r a effing frog in a well.. get over it ppl from around the globe have different accent of eng. u dont understand it can be acceptable n u can watch someone else if its just irritating u, u r a narrow minded person

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

      Divya Sasidharan well said

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

    u r not able to explain in that good manner!!!!
    disappointment