CS FundamentalsModerateProduct-company MCQ pattern
A B+ tree index supports efficient range queries because leaf nodes are linked in sorted order. For a query `WHERE age BETWEEN 25 AND 35`, what is the general access pattern?
- A. Binary search the entire leaf level without using the root at all
- B. Rebuild the index from scratch for every range query
- C. Scan the ENTIRE table, since ranges can't use an index
- D. Traverse from the root to the leaf containing 25 (or the first key ≥ 25), then follow the leaf-level linked list forward, collecting matching entries until a key exceeding 35 is reached
Correct answer: D. Traverse from the root to the leaf containing 25 (or the first key ≥ 25), then follow the leaf-level linked list forward, collecting matching entries until a key exceeding 35 is reached
A single root-to-leaf descent locates the starting point of the range; from there, the index simply follows the sequence set (the linked list connecting sibling leaf nodes) sequentially, collecting qualifying entries without needing to redescend the tree for each one — this sequential-leaf-scan is exactly why B+ trees (not plain B-trees or hash indexes) are preferred for range-heavy workloads.
More DBMS and SQL questions
- A table is partitioned by RANGE on a date column (e.g. one partition per year). A query filters WHERE saledate BETWEEN '2023-01-01' AND…
- A relation R(A, B, C, D, E) has FDs AB → CDE and E → B. What are the candidate key(s) of R?
- Using the same R(A, B, C, D, E) with AB → CDE and E → B, how many superkeys does R have in total?
- R(A, B, C) has NO nontrivial functional dependencies at all (every attribute is independent of every other). What is R's only candidate…
- A relation R(A, B, C, D) has FDs A → BC and D → A (so D is also, indirectly, able to derive B and C). What are the candidate keys of R?
- A trigger-based implementation of a materialized view manually re-runs the entire defining query and replaces all the materialized rows…