Lecture 6 : Dynamic Hashing - PowerPoint PPT Presentation

About This Presentation
Title:

Lecture 6 : Dynamic Hashing

Description:

Related bucket is split. Different hash function is used. C 1 records are rehashed ... Store a record in a bucket pointed by the index ... – PowerPoint PPT presentation

Number of Views:549
Avg rating:3.0/5.0
Slides: 15
Provided by: cau2
Category:

less

Transcript and Presenter's Notes

Title: Lecture 6 : Dynamic Hashing


1
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

3
Virtual Hashing
  • Use more than one hashing functions
  • Hash function use modular function
  • H0 address key N (N20 X N)
  • of buckets N
  • Size of bucket C
  • When overflow occurs
  • Related bucket is split
  • Different hash function is used. C1 records are
    rehashed
  • Hj address key (2j X N ) , j0, 1, 2,

4
Virtual Hashing Example
Bucket 3
  • 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 3

3 103 203 303
3 203 403
103 303
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
  • N20, C3

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, 1159pm)
  • 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.
Write a Comment
User Comments (0)
About PowerShow.com