Presentation is loading. Please wait.

Presentation is loading. Please wait.

Additional notes on Hashing And notes on HW4. Selected Answers to the Last Assignment The records will hash to the following buckets: K h(K) (bucket number)

Similar presentations


Presentation on theme: "Additional notes on Hashing And notes on HW4. Selected Answers to the Last Assignment The records will hash to the following buckets: K h(K) (bucket number)"— Presentation transcript:

1 Additional notes on Hashing And notes on HW4

2 Selected Answers to the Last Assignment The records will hash to the following buckets: K h(K) (bucket number) overflow overflow Two records out of 15 are in overflow, which will require an additional block access. The other records require only one block access. Hence, the average time to retrieve a random record is: (1 * (13/15)) + (2 * (2/15)) = = block accesses

3 Now if you were asked to do this with extendible hashing record record record record record record record record record record record record record record record

4 Lets go through the first few steps K mod 2 (2369 and 4871) in bucket 1, (3760 and 4692) in bucket 0. Now the next record is going to cause a split to K mod 4 – The key in extendible hashing is only the bucket that overflow needs to be split – for the other buckets you just use pointer de-referencing – record 5659 – will leave bucket 0 unchanged but the pointer derferences will need to be fixed – Hash element 00 will both point to bucket 0 – Hash element 11 will point to the bucket containing records 4871 and 5659 (both ending in 11) and Hash element 01 will point to record containing – Then 1821 will get added to the bucket containing – Now adding 1074 – the hash entry 10 will point to the new block containing this element – Now adding record 8 (01011) will cause a split and we will need to go to K Mod 8. – And so on.

5 Now if you were to do extendible hashing by remapping (linear hash) This one simply remaps all the data from scratch while using the next hash function K mod 2, K mod 4, K mod 8 The tradeoff is access cost is fixed constant – no dereferencing – The disadvantage is remapping frequently.


Download ppt "Additional notes on Hashing And notes on HW4. Selected Answers to the Last Assignment The records will hash to the following buckets: K h(K) (bucket number)"

Similar presentations


Ads by Google