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.7 Files of Ordered Records (Sorted Files)faster access rvhen the binary searcl-r technique is used, which constitutes an improvementover linear searches, although it is not often used for disk files.A binary search for disk files can be done on the blocks rather than on the records.Suppose that the file has b blocks numbered 1,2,..., b; the records are ordered byascending value of their ordering key field; <strong>and</strong> we are searchir.rg for a record whoseordering key field vah-re is K. Assunring that disk addresses of the flle blocks are availabiein the file header, the bir-rary search c:rn be described by Algorithm l 3. 1 . A binarysearch usually accesses log,(b) blocks, whether the record is found or not-animprovement over linear searches, rvhere, on the average, (lrl2) blocks are accessedwhen the record is found <strong>and</strong> b blocks are accessed when the record is not found.Algorithm <strong>13.1</strong>. Binary Search on an Ordering Key of a Disk FileI

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

Saved successfully!

Ooh no, something went wrong!