S1: A hash index must be a dense index
S2: A tree index can be a sparse index
Which one of the following options is correct?
A
Step-by-Step Solution
Insight: Hash indices are unordered and require an entry for every key to locate records (dense), whereas B+ trees are ordered and can act as a sparse primary index if the file is ordered by the same key.
Exam route: Evaluate S1: Hash index lacks order, so sparse indexing (which relies on file order) is impossible. Thus, S1 is true. Evaluate S2: A B+ tree index can be clustered (primary) and sparse, storing only the first key of each data block. Thus, S2 is true. Both are true.
Learning route:
- Dense index: entry for every search key.
- Sparse index: entry for only some keys (e.g., one per block), strictly requires the data file to be physically sorted on the index key.
- S1 (Hash index): A hash function computes a bucket address directly. It does not maintain search keys in sorted order. Therefore, you cannot skip keys or point to block anchors. Every search key must have its own entry. S1 is true.
- S2 (B+ tree index): A B+ tree maintains keys in sorted order. If built on the ordering key of a sequentially sorted file, it acts as a primary index. It can be implemented as a sparse index where internal nodes or leaf entries point to data blocks rather than individual records. S2 is true.
Conclusion: Both S1 and S2 are true.