Dynamic Perfect Hashing By: Tomer Shlomi Dynamic Perfect Hashing: Upper and Lower Bounds – Martin Dietzfelbinger, Anna Karlin, Kurt Mehlhorn, Friedhelm.

Slides:



Advertisements
Similar presentations
1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
Advertisements

An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
Lecture 6 Hashing. Motivating Example Want to store a list whose elements are integers between 1 and 5 Will define an array of size 5, and if the list.
Lecture 11 oct 6 Goals: hashing hash functions chaining closed hashing application of hashing.
Msb(x) in O(1) steps using 5 multiplications Word size n = g∙g, g a power of 2 [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound.
Data Structures: A Pseudocode Approach with C
© 2004 Goodrich, Tamassia Hash Tables1  
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 11.
Hashing CS 3358 Data Structures.
Dictionaries and Hash Tables1  
11.Hash Tables Hsu, Lih-Hsing. Computer Theory Lab. Chapter 11P Directed-address tables Direct addressing is a simple technique that works well.
Look-up problem IP address did we see the IP address before?
HASHING CSC 172 SPRING 2002 LECTURE 22. Hashing A cool way to get from an element x to the place where x can be found An array [0..B-1] of buckets Bucket.
REPRESENTING SETS CSC 172 SPRING 2002 LECTURE 21.
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
CSE 326: Data Structures Hashing Ben Lerner Summer 2007.
Hash Tables1 Part E Hash Tables  
This material in not in your text (except as exercises) Sequence Comparisons –Problems in molecular biology involve finding the minimum number of edit.
Hash Tables1 Part E Hash Tables  
Hashing COMP171 Fall Hashing 2 Hash table * Support the following operations n Find n Insert n Delete. (deletions may be unnecessary in some applications)
Hash Tables1 Part E Hash Tables  
Lecture 10: Search Structures and Hashing
Tirgul 7 Heaps & Priority Queues Reminder Examples Hash Tables Reminder Examples.
Lecture 11 oct 7 Goals: hashing hash functions chaining closed hashing application of hashing.
Hashing General idea: Get a large array
L. Grewe. Computing hash function for a string Horner’s rule: (( … (a 0 x + a 1 ) x + a 2 ) x + … + a n-2 )x + a n-1 ) int hash( const string & key )
Lecture 6 Hashing. Motivating Example Want to store a list whose elements are integers between 1 and 5 Will define an array of size 5, and if the list.
Data Structures Hashing Uri Zwick January 2014.
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
Spring 2015 Lecture 6: Hash Tables
Symbol Tables Symbol tables are used by compilers to keep track of information about variables functions class names type names temporary variables etc.
Hash Tables Universal Families of Hash Functions Bloom Filters Wednesday, July 23 rd 1.
Implementing Dictionaries Many applications require a dynamic set that supports dictionary-type operations such as Insert, Delete, and Search. E.g., a.
Hash Tables1   © 2010 Goodrich, Tamassia.
David Luebke 1 10/25/2015 CS 332: Algorithms Skip Lists Hash Tables.
Binary Search Tree Qamar Abbas.
© 2004 Goodrich, Tamassia Hash Tables1  
1 Hashing - Introduction Dictionary = a dynamic set that supports the operations INSERT, DELETE, SEARCH Dictionary = a dynamic set that supports the operations.
CSC 172 DATA STRUCTURES. SETS and HASHING  Unadvertised in-store special: SETS!  in JAVA, see Weiss 4.8  Simple Idea: Characteristic Vector  HASHING...The.
Implicit Dictionaries with O(1) Modifications per Update and Fast Search Gianni Franceschini and Ian Munro  Elements kept in 1 st n positions of an array.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
Hashing 1 Hashing. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
The Set ADT List and Tree Implementations CSCI 2720 Spring 2007 Eileen Kraemer.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
Data Structures Using C++
CS6045: Advanced Algorithms Data Structures. Hashing Tables Motivation: symbol tables –A compiler uses a symbol table to relate symbols to associated.
Hashing TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA Course: Data Structures Lecturer: Haim Kaplan and Uri Zwick.
1 Resolving Collision Although collisions should be avoided as much as possible, they are inevitable Need a strategy for resolving collisions. We look.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
Hash Tables 1/28/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
CSC 172 DATA STRUCTURES.
lsb(x) = Least Significant Bit ?
Hash table CSC317 We have elements with key and satellite data
CSCI 210 Data Structures and Algorithms
Sorting Algorithms.
Hashing CSE 2011 Winter July 2018.
Dictionaries Dictionaries 07/27/16 16:46 07/27/16 16:46 Hash Tables 
Richard Anderson (instead of Martin Tompa)
COMS E F15 Lecture 2: Median trick + Chernoff, Distinct Count, Impossibility Results Left to the title, a presenter can insert his/her own image.
Arrays and Linked Lists
תרגול 6 AVL Trees.
Dictionaries 1/17/2019 7:55 AM Hash Tables   4
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
A Hash Table with Chaining
Design and Analysis of Algorithms
Hashing.
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Chapter 12&13: Binary Search Trees (BSTs)
Lecture-Hashing.
Presentation transcript:

Dynamic Perfect Hashing By: Tomer Shlomi Dynamic Perfect Hashing: Upper and Lower Bounds – Martin Dietzfelbinger, Anna Karlin, Kurt Mehlhorn, Friedhelm Meyer Auf Der Heide, Hans Rohnert and Robert E. Tarjan

U={0,1,…,N-1} S  U Lookup(S,x) – Returns true if S contains x. Construct data structure in O(n) amortized time. Lookup() takes O(1) time in the worse case. Perfect Hashing

K=2 T[0] T[1] T[2] T[3] T[4] T[5] b 0 =1k 0 =115 b 4 =2k 4 =152 Perfect Hashing Hash functions: h k =(kx mode p) mod s

Dynamic Perfect Hashing Insert(S,x) – insert a new element to S Delete(S,x) – delete an element from S Insert() and Delete will take time O(1) amortized while Lookup(S,x) remains in O(1) worse case !

Procedure Insert(x) Count = Count + 1; If (Count > M) then RehashAll(x) else j = h(x); If (Position h j (x) of subtable T j contains x) then if (x is marked “deleted”) then remove the tag; else do nothing; else b j = b j + 1;

If (b j <= m j ) then If position h j (x) of T j is empty then store x in position h j (x) of T j ; else ReArrange(j, x); Else m j = 2 * max{1,m j }; s j = 2*m j (m j -1); if (condition (**) is still satisfied) then Allocate s j cells for T j ; ReArrange(j, x); else RehashAll(x);

Procedure ReArrange(j, x) Put all non deleted elements of T j in List L j ; Append x to list L j ; b j = length of L j ; Repeat h j = randomly chosen function in H sj ; Until h j is injective on the elements of L j ; For all y on list L j, store y in position h j (y) of T j ;

Procedure RehashAll(x) Put all non deleted elements of T in list L; If (x in U) then append x to L; Count = length of list L; M = (1+c)max{Count, 4}; Repeat h=randomly chosen function in H s(M) For all j<s(M) do form a list L j for h(x) = j, b j = length of L j, m j = 2b j, s j = 2m j (m j -1) Until condition (**) is satisfied; For all j<s(M) do Allocate space s j for subtable T j ; Repeat h j = randomly chosen function in H sj ; Until h j is injective on the elements of list L j ; For all x on list L j store x in position h j (x) of T j ; `12

Procedure Delete(x) count=count+1 j=h(x); if position h(x) of subtable Tj contains x them mark x as “deleted” else return(x is not a member of S); if (count>=M) then RehashAll(-1)

Procedure Lookup(x) j=h(x); if (position h(x) of subtable Tj contains x (not deleted)) them return(x is a member of S) else return(x is not a member of S);

Lemma – phase space The memory space used during a phase that starts with n keys being stored in the dictionary is O(n).

Lemma – phase time The expected time for a phase that starts with n keys being stored in the dictionary is O(n). Claim: Assume a hash function hj is chosen for Tj at the beginning or in the course of a subphase. Then the probability that hj stays in use until the end of the subphase exceeds ½.

Lemma – not so many phases a. With probability exceeding ½ we have: b. If the inequality in (a) is satisfied for the level-1 function h chosen at the beginning of the phase, then the phase ends with the variable count reaching M.

Lemma – c*n updates time Suppose that RehashAll is called at a time when n  1 keys are stored in the dictionary. Then the (expected) time needed until the first call the RehashAll after c*n updates have been performed is O(n).

X-Fast Trie U={1,…,M} S  U|S| = N Member(x) – if x  S return true Successor(x) – the smallest element in S that is bigger than x Predecessor(x) – the biggest element in S that is smaller than x All operations in O(Log(Log M)) time worse case. Total space of O(NLogM). The space can be reduced to O(N) in Y- Fast Trie.

Dynamic X-Fast Trie Insert(x) – Add element to S Delete(x) – Delete an element from S Insert() and Delete() in O(LogM) expected amortized time. Member() in O(1) worse case. Successor() and Predecessor() in O(Log(Log M)) time worse case. Total space of O(NLogM).

Dynamic X-Fast Trie example {0,1} {010,011,101} {01,10} {0101,0110, 0111,1011}