3.3.8 · HinglishHashing

Universal hashing — probabilistic guarantee

1,629 words7 min readRead in English

3.3.8 · Coding › Hashing


"Universal" ka actually matlab kya hai


Performance guarantee ko scratch se derive karna

Maano hum keys ko slots wale ek chained hash table mein insert karte hain, universal family se randomly choose kiya hua use karke. Hum chahte hain ki ek given key ke saath collide karne wali keys ki expected number kya hogi.

Figure — Universal hashing — probabilistic guarantee

Ek concrete universal family (taaki yeh abstract na rahe)


Worked examples


Recall Feynman: ek 12-saal ke bachche ko explain karo

Socho ek bully hamesha wahi locker choose karta hai jo already bhara hua ho taaki tum apna saman nahi rakh sako. Agar tumhara locker-picking rule fixed hai, toh woh hamesha jeetta hai. Toh uske bajaye, class se pehle secretly dice roll karo rule decide karne ke liye. Ab bully ko nahi pata ki cheezein kaunse lockers mein gayi hain, toh average mein sab ko apna locker milta hai aur koi zyada wait nahi karta. Dice (random choice of ) tumhara secret hai, aur wahi use beat karta hai — yeh nahi ki bachche "random" hain.


Flashcards

When is a family called universal?
Har distinct ke liye, , jab uniformly at random choose kiya gaya ho.
Where does the randomness live in universal hashing?
Family se hash function ke choice mein — keys mein NAHI, jo adversarial ho sakti hain.
Why use linearity of expectation in the analysis?
Yeh hamare liye ko bina independence assume kiye sum karne deti hai, aur collisions dependent hoti hain.
Expected number of keys colliding with (x not inserted)?
(the load factor).
Expected cost of a search with universal hashing?
; jab ho toh hai.
State the classic universal family .
, prime max key ke saath, , .
Is exactly universal?
Sirf jab (). General case mein yeh almost-universal hai jab .
Why must in ?
Taaki map ek bijection ho, jo ensure kare ki distinct keys mod distinct residues dein.
What does universal hashing protect against that fixed hashing cannot?
Ek adversary jo worst-case keys choose kare taaki saari collisions force ho sakein.
equals what?
, kyunki ek 0/1 indicator hai.

Connections

Concept Map

defeated by adversary

degrades to

avoids

must satisfy

for distinct x y

equals expectation

summed via

gives

with load factor

chain length

keep m equals theta n

Fixed hash function

Adversary forces collisions

O of n operations

Pick h randomly from family H

Universal property

Pr collision at most 1 over m

Indicator E of Xxy

Linearity of expectation

E of X at most n-1 over m

alpha equals n over m

Expected 1 plus alpha

Expected O of 1 per operation