Presentation on theme: "Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University."— Presentation transcript:
Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University
2 Dynamic Hashing A hash table that grows to handle more items Virtual Hashing Dynamic Hashing Extendible Hashing Linear Hashing
Virtual Hashing Use more than one hashing functions Hash function : use modular function H0 : address = key % N (N=2^0 X N) # of buckets : N Size of bucket : C When overflow occurs Related bucket is split Different hash function is used. C+1 records are rehashed Hj : address = key % (2^j X N ), j=0, 1, 2, …
Virtual Hashing Example N = 100, C = 4 bucket 3 is full : [3, 103, 203, 303] H0 = key % 100 Overflow! when new record 403 is inserted Use h1 = key % 200 and split bucket Bucket 3 Bucket 103
Virtual Hashing Overflow when 603, 803 are inserted Use h2 = key % 400 to split buckets What happens? When a key is searched, what hash function to apply? Problems How to handle the space between two split buckets?
Dynamic hashing # of buckets : N Bucket size : C We have indices pointing to each bucket Example N=20, C=3
Dynamic Hashing Use two functions Hashing function H0 obtain index entry # Each index entry is corresponding to binary tree root Determine which binary tree Bit function B convert key to Bit String (bit string size is controlled) Decide which branch within each index binary tree
Dynamic hashing algorithm Convert key into index using H0 Store a record in a bucket pointed by the index If the bucket is full, split the bucket and make a binary tree and assign the record into appropriate binary tree node(bucket)
Dynamic hashing H0(key) determine binary tree root node B(key) determine branch direction
Dynamic hashing : example B(key) 0 : left, 1 : right
Insert records 157, 95, 88, 205, 13
Insert record 125 additionally
Insert records 301, 6
Design Project (due : Nov 12, 11:59pm) Description Design and implement your own dynamic hashing algorithm where hash table size can grow dynamically. Submit 1 : Report Your algorithm description including figures Performance (compare with other trivial method such as re-hashing) Show tables and graphs(plots) as much as possible. Strength & weakness of your algorithm Your report should be concise and easy to understand though it should contain essential information on your method and implementation Submit 2 : source code source code that includes your algorithm When executing your code, the program should print detailed description on the events that occur in hash table for each operation.