1. **State the problem:** We have a table with 300,000,000 rows and a dense, sorted index. Each index block is 4 kilobytes (4,000 bytes), and each index entry is 20 bytes. We want to find approximately how many blocks are read during a binary search for one row.
2. **Formula and rules:** In a dense index, each row has an index entry. The number of index entries equals the number of rows, which is 300,000,000.
The number of index entries per block is given by:
$$\text{entries per block} = \frac{\text{block size in bytes}}{\text{entry size in bytes}} = \frac{4000}{20} = 200$$
The total number of index blocks is:
$$\text{total blocks} = \frac{\text{total entries}}{\text{entries per block}} = \frac{300,000,000}{200} = 1,500,000$$
3. **Binary search steps:** Binary search on the index blocks requires reading approximately:
$$\log_2(\text{total blocks}) = \log_2(1,500,000)$$
Calculate:
$$\log_2(1,500,000) = \frac{\log_{10}(1,500,000)}{\log_{10}(2)}$$
Using approximate values:
$$\log_{10}(1,500,000) \approx 6.1761$$
$$\log_{10}(2) \approx 0.3010$$
So:
$$\log_2(1,500,000) \approx \frac{6.1761}{0.3010} \approx 20.52$$
4. **Interpretation:** Since you cannot read a fraction of a block, the number of blocks read is approximately 21.
**Final answer:** Approximately **21 blocks** are read during a binary search for one row in the dense, sorted index.
Binary Search Blocks C486B5
Step-by-step solutions with LaTeX - clean, fast, and student-friendly.