0% found this document useful (0 votes)
45 views2 pages

4D2-Tutorial Solution3 v1.0

The document discusses three questions about file organization and access methods. Question 1 analyzes a file with 50,000 fixed-length records of 100 bytes each, stored in blocks of 1024 bytes. It determines that there would be 10,000 blocks needed to store the file, and that a binary search would require approximately 13 block accesses. Question 2 examines a file with a 15-byte ordering key and 5-byte block pointer stored in index entries of 20 bytes each. It calculates that the index would require 196 blocks and a binary search would need 9 block accesses - 8 for the index plus 1 for the data block. Question 3 compares linear search at 5,000 block accesses to a secondary

Uploaded by

Monir Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

4D2-Tutorial Solution3 v1.0

The document discusses three questions about file organization and access methods. Question 1 analyzes a file with 50,000 fixed-length records of 100 bytes each, stored in blocks of 1024 bytes. It determines that there would be 10,000 blocks needed to store the file, and that a binary search would require approximately 13 block accesses. Question 2 examines a file with a 15-byte ordering key and 5-byte block pointer stored in index entries of 20 bytes each. It calculates that the index would require 196 blocks and a binary search would need 9 block accesses - 8 for the index plus 1 for the data block. Question 3 compares linear search at 5,000 block accesses to a secondary

Uploaded by

Monir Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Question 1

• Ordered file of r=50000 records


• Block size B =1024 bytes
• Records Fixed sized and unspanned with record length R=100 bytes
• (a) Blocking Factor Bfr = B/R = 1024/200 = 5 records per
block
• (b) Number of blocks needed for file is
• b= r/bfr = 50000/5 = 10000 blocks
• (c) A binary search on the data file would need
approx
• log2b = log210000 = 13 block accesses

Question 2
•ordering key V=15bytes long and block pointer P=5bytes long
•Size of each index entry Ri = 20 bytes
•(a) Blocking factor bfri = 1024/20 = 51 entries per block
•(b) Number of entries ri = number of blocks in data file
Number of blocks needed for index is
• bi= ri/bfri = 10000/51 = 196 blocks
•(c) A binary search of index file would need
• log2bi = log2196 = 8 block accesses
•PLUS one block access into the data file itself using the
pointer
(d) Therefore 9 block accesses needed

1
Question 3
(a) Linear search requires b/2=10000/2=5000 block accesses
Suppose a secondary index on a field of V=9bytes
Thus Ri = 9+6 = 15bytes
(b) bfri = B/Ri = 1024/15 = 68 entries per block
Number of index entries ri = number of records = 50,000
Number of blocks need is bi= ri/bfri = 50000/68 = 735 blocks
(c) A binary search of index file would need
log2bi = log2735 = 10 block accesses
PLUS one block access into the data file itself using the
pointer
(d) Therefore 11 block accesses

You might also like