13.07.2015 Views

13.1 through 13.5, 13.10 and 13.11

13.1 through 13.5, 13.10 and 13.11

13.1 through 13.5, 13.10 and 13.11

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

13.8 Hashing Techniques 491s mayMain bucketsBucket 0340f diskrltiple;. TheLn8 annvertsted in.vill fiter, wea newing inds forrld be,sitiongivenintain'ingtmost:cordsltegerBucket 1Bucket 2Bucket 9460321761917252239989Record pointerRecord pointerRecord pointerRecord pointer-l--}NULLOverflow buckets981 Record pointerRecord pointer182 Record pointer652 Record pointerRecord pointerRecord pointer-l(Pornters are to records within the overflow blocks)NULLNULLFigure <strong>13.1</strong>0H<strong>and</strong>ling overflow forh,h.,uuLn ^1.^+^ srJ uy Lr ^h^t^ r4il r ^^ !r9,hash key directly as an index to a relative file, if the hash key values fill up a particularinterval; for example, if employee numbers in a company are assigned as l, 2, 3,. . . up to the total number of employees, we can use the identity hash function thatmaintains order. Unfortunately, this only works if keys are generated in order bysome application.The hashing scheme described is called static hashing because a fixed number ofbuckets M is allocated. This can be a serious drawback for dynamic files. Supposethat we allocate M buckets for the address space <strong>and</strong> let m be the maximum numberof records that can fit in one bucket; then at most (rn x M) records will fit in theallocated space. If the number of records turns out to be substantially fewer than (m* M),we are Ieft with a lot of unused space. On the other h<strong>and</strong>, if the number ofrecords increases to substantially more than (m * M), numerous collisions willresult <strong>and</strong> retrieval will be slowed down because of the long lists of overflowrecords. In either case, we may have to change the number of blocks M allocated <strong>and</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!