This preview shows pages 1–3. 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: 6.851: Advanced Data Structures Spring 2010 Lecture 14 March 30, 2010 Prof. Andr e Schulz Scribe: Rishi Gupta 1 Overview In the last lecture we covered the Separator Decomposition, which rearranges any tree into a balanced tree, and the ART/leaftrimming Decomposition, which is a tree decomposition used to solve the marked ancestor problem and decremental connectivity problem. In this lecture we talk about solutions to the static and dynamic dictionary problem . Our goal is to store a small set S = { 1 , 2 ,...,n } of keys from a large universe U , with perhaps some information associated to every key. We want to find a compact data structure with low preprocessing time that will support Query( x ) in the static case and Query( x ), Insert( x ), and Delete( x ) in the dynamic case. Query( x ) checks if x S , and returns any information associated with x . In particular, FKS hashing achieves O (1) worstcase query time with O ( n ) expected space and takes O ( n ) construction time for the static dictionary problem. Cuckoo Hashing achieves O ( n ) space, O (1) worstcase query and deletion time, and O (1) amortized insertion time for the dynamic dictionary problem. 2 Hashing with Chaining Our first attempt at a dictionary data structure is hashing with chaining . We find a hash function h : U { 1 , 2 ,...,m } , and maintain a table T with m rows, where T [ j ] = a linked list (or chain) of { x S : h ( x ) = j } . Key look up takes P  T [ j ]  2 2 P  T j  expected time, so we want to make the chains as equal as possible. We also generally want h to be easy to evaluate. Luckily, such hash functions exist 1 : 2.1 Universal Hashing Definition 1. A class of functions H is cuniversal if and only if for all x 6 = y , { h H : h ( x ) = h ( y ) } c H m . In particular, if h is picked at random from H , Pr [ h ( x ) = h ( y )] c m . We assume for the rest of this section that m = O ( n ). 1 Its worth noting that a random function from U to { 1 ,...,m } would actually have O(1) expected query time (provided n = O ( m )). However, such a random function would be infeasibly inefficient to store and evaluate. 1 Define Z x := { y S : h ( x ) = h ( y ) } , namely, the collisions with x in the set of elements we want to store. We can also write this as Z x = y h ( x ) ,h ( y ) , where is the Kronecker delta ( a,b = 1 if a = b and 0 otherwise). The average query time is simply E [ Z x ], and we have E [ Z x ] = E " X y h ( x ) ,h ( y ) # = X y E [ h ( x ) ,h ( y ) ] = 1 + X y 6 = x Pr [ h ( x ) = h ( y )] = 1 + nc m = O (1) ....
View
Full
Document
This note was uploaded on 01/20/2012 for the course CS 6.849 taught by Professor Erikdemaine during the Fall '10 term at MIT.
 Fall '10
 ErikDemaine
 Data Structures

Click to edit the document details