Exam
Typed page for exam
•
ASSUME
o
Average case analysis
(not malicious adversary)
(Uniformly distributed random inputs)
o
Simple uniform hashing
For any given hash function, if given a key it will uniformly distribute
throughout the table
The cost (in collisions) of find () in a chained hash table with n keys =
θ(n/m)
•
Hash Function Choice
o
Output should be uniform on (o…m-1)
o
Avoid patters on typical inputs
•
Idea #1
o
Division Hashing
H(k) = k mod m
•
Diffusion
o
Used in Cryptographic Hashing
o
One change causes a huge change in output
o
Advice
Use a odd prime number for m
o
Need good diffusion so you can protect yourself against stupidity
•
Multiplicative hashing
o
Let A be a constant, 0<A<1
o
H(k) = math.floor(m(KA-int(KA)))
(KA-int(KA)
•
Returns a number between [0…1)
m(KA-int(KA)
•
Returns a number between [0…m)
math.floor(m(KA-int(KA)))
•
returns a int inclusive [0…m-1]
o
Ideas:
“A” should be irrational
Between (1/2, 1)
Eg. Good choice =
•

This preview has intentionally blurred sections.
Sign up to view the full version.

This is the end of the preview.
Sign up
to
access the rest of the document.
- Spring '11
- Cytron
- Computer Science, hash function, Prime number, simple uniform hashing, Exam Typed page
-
Click to edit the document details