Presentation is loading. Please wait.

Presentation is loading. Please wait.

HASH TABLES Malathi Mansanpally CS_257 ID-220. Agenda: Extensible Hash Tables Insertion Into Extensible Hash Tables Linear Hash Tables Insertion Into.

Similar presentations


Presentation on theme: "HASH TABLES Malathi Mansanpally CS_257 ID-220. Agenda: Extensible Hash Tables Insertion Into Extensible Hash Tables Linear Hash Tables Insertion Into."— Presentation transcript:

1 HASH TABLES Malathi Mansanpally CS_257 ID-220

2 Agenda: Extensible Hash Tables Insertion Into Extensible Hash Tables Linear Hash Tables Insertion Into Linear Hash Tables

3 Extensible Hash Tables Definition: Dynamic Hashing: A hash table that grows to handle more items. The associated hash function must change as the table grows. Some schemes may shrink the table to save space when item are deleted.

4 Contd.. Extendable hashing is one form of dynamic hashing. Extendable hashing splits and coalesces buckets as database size changes. A hash table in which the hash function is the last few bits of the key and the table refers to buckets.

5 i=1 1 1 0001 1001 1100 0 1 Buckets Data blocks

6 Insertion Into Extensible Table Insertion into an extensible hash table begins like insertion into a static hash table. To insert a record with search key K, we compute h(K). Whereas i is the part of the hash data structure.

7 i=2 1 2 2 00 01 10 11 0001 1001 1010 1100

8 i=3 2 2 3 3 2 000 100 011 101 110 010 001 111 0000 0001 0111 1000 1001 1010 1100

9 Linear Hash Tables Linear hashing allows for the expansion of the hash table one slot at a time. The frequent single slot exapnsion can very effectively control the length of the collision chain. In linear hashing, I bits of the hash functions are being used to number array entries and a record with key K is intended for bucket a1a2…….ai and last i bits of h(K).

10 Contd.. i=1 N=2 R=3 0 1 0000 1010 1111

11 Insertion Into Linear Hash Tables We insert a new record, by determining its bucket by the algorithm outlined in above topic. Here we compute h(K), where K is the key of the record. i bits at the end of bit sequence h(K) as the bucket number, m.

12 Contd.. If m<n, we put the record in m If m>=n, we put the record in bucket m-2^i-1 Here each time we insert, we compare the current number of records r with the threshold ratio of r/n and if the ratio is too high, we add the next bucket to the table.

13 i=2 n=3 r=4 0000 1010 1111 00 01 1010 0101 10

14 i=2 n=3 r=5 0000 1010 0101 00 01 1010 0001 10 1111

15 i=2 n=4 r=6 0000 1010 0101 00 01 1010 0001 10 0111 1111 11

16 THANK YOU


Download ppt "HASH TABLES Malathi Mansanpally CS_257 ID-220. Agenda: Extensible Hash Tables Insertion Into Extensible Hash Tables Linear Hash Tables Insertion Into."

Similar presentations


Ads by Google