Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.

Similar presentations


Presentation on theme: "Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University."— Presentation transcript:

1 Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University

2 2 Dynamic Hashing A hash table that grows to handle more items Virtual Hashing Dynamic Hashing Extendible Hashing Linear Hashing

3 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, …

4 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

5 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?

6 Dynamic hashing # of buckets : N Bucket size : C We have indices pointing to each bucket Example N=20, C=3

7 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

8 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)

9 Dynamic hashing H0(key) determine binary tree root node B(key) determine branch direction

10 Dynamic hashing : example B(key) 0 : left, 1 : right

11 Insert records 157, 95, 88, 205, 13

12 Insert record 125 additionally

13 Insert records 301, 6

14 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.


Download ppt "Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University."

Similar presentations


Ads by Google