lecture08 - Introduction to Algorithms...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 8 Prof. Charles E. Leiserson
Background image of page 1

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

View Full DocumentRight Arrow Icon
Introduction to Algorithms Day 12 L8.2 © 2001 by Charles E. Leiserson A weakness of hashing Problem: For any hash function h , a set of keys exists that can cause the average access time of a hash table to skyrocket. I DEA : Choose the hash function at random, independently of the keys. Even if an adversary can see your code, he or she cannot find a bad set of keys, since he or she doesn’t know exactly which hash function will be chosen. An adversary can pick all keys from { k U : h ( k ) = i } for some slot i .
Background image of page 2
Introduction to Algorithms Day 12 L8.3 © 2001 by Charles E. Leiserson Universal hashing Definition. Let U be a universe of keys, and let H be a finite collection of hash functions, each mapping U to {0, 1, …, m –1} . We say H is universal if for all x , y U , where x y , we have |{ h H : h ( x ) = h ( y )}| = | H |/ m . That is, the chance of a collision between x and y is 1/ m if we choose h randomly from H . H { h : h ( x ) = h ( y )} | H | m
Background image of page 3

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

View Full DocumentRight Arrow Icon
Introduction to Algorithms Day 12 L8.4 © 2001 by Charles E. Leiserson Universality is good Theorem. Let h be a hash function chosen (uniformly) at random from a universal set H of hash functions. Suppose h is used to hash n arbitrary keys into the m slots of a table T . Then, for a given key x , we have E [#collisions with x ] < n / m .
Background image of page 4
Day 12 L8.5 © 2001 by Charles E. Leiserson Proof of theorem Proof. Let C x be the random variable denoting the total number of collisions of keys in T with x , and let c xy = 1 if h ( x ) = h ( y ) , 0 otherwise. Note:
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/09/2009 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

Page1 / 19

lecture08 - Introduction to Algorithms...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online