This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 70 Discrete Mathematics and Probability Theory Spring 2010 Alistair Sinclair Note 13 Two Killer Applications In this lecture, we will see two killer apps of elementary probability in Computer Science. 1. Suppose a hash function distributes keys evenly over a table of size n . How many (randomly chosen) keys can we hash before the probability of a collision exceeds (say) 1 2 ? 2. Consider the following simple load balancing scenario. We are given m jobs and n machines; we allocate each job to a machine uniformly at random and independently of all other jobs. What is a likely value for the maximum load on any machine? As we shall see, both of these questions can be tackled by an analysis of the ballsandbins probability space which we have already encountered. Application 1: Hash functions As you may recall, a hash table is a data structure that supports the storage of sets of keys from a (large) universe U (say, the names of all 250m people in the US). The operations supported are ADDing a key to the set, DELETEing a key from the set, and testing MEMBERship of a key in the set. The hash function h maps U to a table T of modest size. To ADD a key x to our set, we evaluate h ( x ) (i.e., apply the hash function to the key) and store x at the location h ( x ) in the table T . All keys in our set that are mapped to the same table location are stored in a simple linked list. The operations DELETE and MEMBER are implemented in similar fashion, by evaluating h ( x ) and searching the linked list at h ( x ) . Note that the efficiency of a hash function depends on having only few collisions i.e., keys that map to the same location. This is because the search time for DELETE and MEMBER operations is proportional to the length of the corresponding linked list. The question we are interested in here is the following: suppose our hash table T has size n , and that our hash function h distributes U evenly over T . 1 Assume that the keys we want to store are chosen uniformly at random and independently from the universe U . What is the largest number, m , of keys we can store before the probability of a collision reaches 1 2 ? Lets begin by seeing how this problem can be put into the balls and bins framework. The balls will be the m keys to be stored, and the bins will be the n locations in the hash table T . Since the keys are chosen uniformly and independently from U , and since the hash function distributes keys evenly over the table, we can see each key (ball) as choosing a hash table location (bin) uniformly and independently from T . Thus the probability space corresponding to this hashing experiment is exactly the same as the balls and bins space....
View
Full
Document
This note was uploaded on 09/21/2010 for the course CS 70 taught by Professor Papadimitrou during the Spring '08 term at University of California, Berkeley.
 Spring '08
 PAPADIMITROU
 Computer Science, The Land

Click to edit the document details