Consider an ordered file with 1,00,000 records stored on a disk using ...
Number of records per block = 2048/256 =8
Size of each index entry = 10+6 = 16.
number of entries per block =2048/16 = 128
Total number of indexes = total number of blocks in file = 100000/8 =12500
So, number of index blocks = ceil(12500/128) = 98
Total number of block access = 1+ceil(log298) =1+7 = 8.
View all questions of this test
Consider an ordered file with 1,00,000 records stored on a disk using ...
Given Information:
- Ordered file with 1,00,000 records
- Un-spanned file organization
- Block size = 2048 bytes
- Record length = 256 bytes
- Primary indexing over a field of size 10 bytes
- Block pointer size = 6 bytes
To find: Number of block accesses required to search for a record.
Solution:
1. Calculation of records per block:
- Block size = 2048 bytes
- Record length = 256 bytes
- Therefore, records per block = 2048/256 = 8 records
2. Calculation of number of data blocks:
- Total records = 1,00,000
- Records per block = 8
- Therefore, number of data blocks = 1,00,000/8 = 12,500 blocks
3. Calculation of index entries per block:
- Block size = 2048 bytes
- Block pointer size = 6 bytes
- Size of index entry = 10 + 6 = 16 bytes
- Therefore, index entries per block = 2048/16 = 128 entries
4. Calculation of number of index blocks:
- Total index entries = 1,00,000
- Index entries per block = 128
- Therefore, number of index blocks = 1,00,000/128 = 781.25 blocks
- Since we cannot have fractional blocks, we round it up to 782 blocks
5. Calculation of total number of blocks:
- Number of data blocks = 12,500
- Number of index blocks = 782
- Therefore, total number of blocks = 13,282 blocks
6. Calculation of number of index blocks to search for a record:
- Since primary indexing is used, we need to search for the record in the index first
- Size of index entry = 16 bytes
- Therefore, number of index entries in a block = 2048/16 = 128 entries
- Size of data block pointer = 6 bytes
- Therefore, number of data block pointers in a block = 2048/6 = 341 pointers
- To search for a record, we need to search for the appropriate index block first, and then search for the data block using the data block pointer in the index block
- To search for an index block, we need to search through the index blocks sequentially, which requires 782/2 = 391 block accesses on average
- Once we find the appropriate index block, we need to search for the data block using the data block pointer in the index block, which requires 1 block access
- Therefore, total number of block accesses required to search for a record = 391 + 1 = 392 block accesses
Therefore, the correct option is (c) 8.