Hash table double hashing

  Рет қаралды 34,645

WilliamFiset

WilliamFiset

Күн бұрын

Пікірлер: 21
@jananir9323
@jananir9323 4 жыл бұрын
This is a great explanation and loving all the videos in the hashing series so far! Thank you!
@nonamehere9658
@nonamehere9658 4 жыл бұрын
About construction of H2(x): You've used (more or less) offset_increment = H2(x) % N, if H2(x) %N !=0, 1 otherwise. However, I think it would be more elegant (and also, make offset_increment uniform in set {1, 2, ... N-1}) by using offset_increment = 1 +H2(x) % (N - 1). Cheers.
@iyadaithou228
@iyadaithou228 5 жыл бұрын
Excellent Content!
@amoghdadhich9318
@amoghdadhich9318 Жыл бұрын
How do we decide on the number to resize to? Is there an algorithm to find the next prime number?
@svrmmb
@svrmmb 10 ай бұрын
en.wikipedia.org/wiki/Generation_of_primes
@magno5157
@magno5157 4 жыл бұрын
Resizing is so expensive
@sarthakshah1058
@sarthakshah1058 6 жыл бұрын
Thank you for the video, it helped me a lot. However, why do we use Quadratic Probing when Linear Probing works?
@WilliamFiset-videos
@WilliamFiset-videos 6 жыл бұрын
I'm not sure there's a particular reason other than a different way to distribute the key-value pairs in the table (for better or worse).
@ThePRINCEBARPAGA
@ThePRINCEBARPAGA 6 жыл бұрын
During Linear Probing items tend to cluster together in a bucket array, as clustering gets worse insertion and find will take longer like O(n).
@BiancaAguglia
@BiancaAguglia 4 жыл бұрын
@@WilliamFiset-videos It would have been nice to see an animation of how specific probing functions lead to different distributions of key-value pairs in the hash table. 😊Still, this is a very helpful and very well done series. Thank you for all the effort you put into it.
@maxxxwan
@maxxxwan 7 жыл бұрын
P(k, x) in your first slide, but in next slides P(x) is used. Why? thanks
@WilliamFiset-videos
@WilliamFiset-videos 7 жыл бұрын
Lifeng W, To be consistent I really should be using P(k,x) everywhere. However, Screen space is limited and simply writing P(x) saves me lots of room. In practice, you want to compute H2(k) only once because it can be expensive and furthermore it's a constant. So there's often no need to actually pass in k as a parameter since H2(k) is known.
@LinhVũNguyễnDuy
@LinhVũNguyễnDuy Жыл бұрын
why H1(k6) +2* delta mod 7 = 0?, why not 7?
@WilliamFiset-videos
@WilliamFiset-videos Жыл бұрын
Multiples of 7 such as 7, 14, 21, 28... modulo 7 equals 0
@sasanktadepalli1231
@sasanktadepalli1231 4 жыл бұрын
Sir, Can u say some examples for Universal Hash functions
@dallasmilanista8291
@dallasmilanista8291 3 жыл бұрын
At 7:39 , you say delta = H2(K2) mod 7 = 5. But H2(k2) = -79. How is -79 mod 7 = 5? Can you please help me understand if I missing something?
@ankitmidha7993
@ankitmidha7993 Жыл бұрын
If you want to evaluate a modulus of a positive number you find the largest number that is less than the number and then find the remainder. Do the same thing for a negative number i.e. find the number that is less than the number and find the remainder. In the case of -79 it is -84 (and not -77 as this is greater than -79). So -79 - (-84) = 5. Hope that helped.
@LinhVũNguyễnDuy
@LinhVũNguyễnDuy Жыл бұрын
@@ankitmidha7993 why is -84? and not 80 (thanks
@Luna-vk9xy
@Luna-vk9xy 4 жыл бұрын
I need to confirm something. Why does N usually preferred to be taken as a prime number? I know for most probing sequences it prevents an infinite cycle of collisions But is there any reason for it? Does it also provide a more uniform distribution of elements within our HT?
@constantijndekker8343
@constantijndekker8343 3 жыл бұрын
Interesting question. From this video, I understood cycle length as the key property. Otherwise you can get the situation where certain slots are filled up and because of that the insertion might reach an infinite loop which is very bad, even if you catch this, what do you tell the user? “Sorry you cannot insert this element, try some other element”? :)
@constantijndekker8343
@constantijndekker8343 3 жыл бұрын
Small addendum. It was not mentioned in the video, but you can also select your second hash function in such a way to avoid these infinite cycles. If you like table sizes of powers of two, you have to make sure H_2 always returns an odd number for instance (or modify it in such a way that it does). I think you would have to do measurements to see if that is an acceptable compromise.
Hash Table Open Addressing Removals
7:33
WilliamFiset
Рет қаралды 25 М.
Hashing Technique - Simplified
17:04
Abdul Bari
Рет қаралды 775 М.
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 9 МЛН
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 98 МЛН
Hash table open addressing
11:09
WilliamFiset
Рет қаралды 28 М.
Hash Tables and Hash Functions
13:56
Computer Science Lessons
Рет қаралды 1,6 МЛН
Hash table hash function
17:21
WilliamFiset
Рет қаралды 44 М.
L-6.4: Linear Probing in Hashing with example
12:40
Gate Smashers
Рет қаралды 550 М.
How to Implement a Hash Table in JavaScript
25:39
Ben Awad
Рет қаралды 104 М.
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 608 М.
Collision Handling in Hash Tables
16:44
Mary Elaine Califf
Рет қаралды 7 М.
Hash table linear probing
13:56
WilliamFiset
Рет қаралды 43 М.
Collision Resolution - Double Hashing Method
8:12
Furkan
Рет қаралды 9 М.
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 9 МЛН