4D2-Tutorial Solution3 v1.0

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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