MIT6_851S10_lec14

MIT6_851S10_lec14 - 6.851 Advanced Data Structures Spring...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
6.851: Advanced Data Structures Spring 2010 Lecture 14 March 30, 2010 Prof. Andr´ e Schulz 1 Overview In the last lecture we covered the Separator Decomposition, which rearranges any tree into a balanced tree, and the ART/leaf-trimming 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 pre-processing 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) worst-case 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) worst-case 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 } . P | T [ j ] | 2 Key look up takes 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 c -universal if and only if for all x = y , |H| . |{ h ∈ H : h ( x ) = h ( y ) }| c · 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 It’s 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
Image of page 1

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

View Full Document Right Arrow Icon
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 nc E [ Z x ] = E δ h ( x ) ,h ( y ) = E [ δ h ( x ) ,h ( y ) ] = 1 + Pr [ h ( x ) = h ( y )] = 1 + = O (1) . m y y y = x All that remains then is to find a class of such c -universal functions. An example of a 2-universal class is H = { h a ( x ) = ( ax (mod p )) (mod m ) } 0 <a<p for a prime p > m .
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern