12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sec. 10.7 Exercises 383(a) Assume that a linear index uses 4 bytes <strong>to</strong> s<strong>to</strong>re the key <strong>and</strong> 4 bytes<strong>to</strong> s<strong>to</strong>re the block ID for the associated records. What is the greatestnumber of records that can be s<strong>to</strong>red in the file if a linear index of size2MB is used?(b) What is the greatest number of records that can be s<strong>to</strong>red in the file ifthe linear index is also s<strong>to</strong>red on disk (<strong>and</strong> thus its size is limited only bythe second-level index) when using a second-level index of 4096 bytes(i.e., 1024 key values) as illustrated by Figure 10.2? Each element ofthe second-level index references the smallest key value for a disk blockof the linear index.10.3 Modify the function binary of Section 3.5 so as <strong>to</strong> support variable-lengthrecords with fixed-length keys indexed by a simple linear index as illustratedby Figure 10.1.10.4 Assume that a database s<strong>to</strong>res records consisting of a 2-byte integer key <strong>and</strong>a variable-length data field consisting of a string. Show the linear index (asillustrated by Figure 10.1) for the following collection of records:397 Hello world!82 XYZ1038 This string is rather long1037 This is shorter42 ABC2222 Hello new world!10.5 Each of the following series of records consists of a four-digit primary key(with no duplicates) <strong>and</strong> a four-character secondary key (with many duplicates).3456 DEER2398 DEER2926 DUCK9737 DEER7739 GOAT9279 DUCK1111 FROG8133 DEER7183 DUCK7186 FROG(a) Show the inverted list (as illustrated by Figure 10.4) for this collectionof records.

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

Saved successfully!

Ooh no, something went wrong!