Database Management Systems · Indexing, Storage & Query Processing
38 questions, newest first
GATE CSE has asked 38 questions on Indexing, Storage & Query Processing (Database Management Systems) from 1993 to 2026, in 28 of the 46 papers; the most recent is in GATE CSE 2026 Set 2. In the last five years it carried 1 marks per 100-mark paper on average, against 0.9 since 2003. Since 2014 the questions have been 7 NAT, 5 MCQ and 2 MSQ. 4 groups of questions here are solved the same way; “One per method” keeps the newest of each.
An index is dense if it has an entry for every search-key value in its indexed file; otherwise it is sparse. S1: a hash index must be dense. S2: a B+ tree index can be sparse. Options: A both true; B both false; C only S1; D only S2.
Your answer
Answer & solution
Official answer: A
Givens and goal
An index is dense if it has an entry for every search-key value in its indexed file; otherwise it is sparse. S1: a hash index must be dense. S2: a B+ tree index can be sparse. Options: A both true; B both false; C only S1; D only S2.
Approach
Ask whether omitted keys can be found from an ordered boundary entry.
Step-by-step solution
1. In the standard hash-index model, searching key k uses h(k) to locate its bucket and then the relevant search-key entry. Hash values do not arrange keys in sorted order, so an entry for a nearby smaller key does not identify where an omitted key belongs. 2. Consequently the search-key index must represent every indexed value: S1 is true under the problem’s dense/sparse definition. A bucket directory is a different structure from the entries for the indexed search-key values. 3. For an ordered data file, a B+ tree can hold just one boundary key per data block. Searching for k finds the appropriate boundary and follows its pointer, then scans that block for k. Most individual keys need not appear in the index. 4. This is a valid sparse B+ tree index, establishing S2. A B+ tree can also be dense, but the statement only says can be sparse. 5. Thus A is correct. Sparseness relies on the supporting ordered-file organization; a sparse boundary index over arbitrary unordered records would not provide this search guarantee.
A pictured B+ tree has a root with keys [6,12,19] and four leaf children, shown left to right as [1,4,3], [7,9,10], [13,15,17], [20,21,22]. Each node holds at most three keys, and there are five nodes initially. Insert 23 using ordinary B+ tree insertion. Which statements hold? A no node splits; B at least one node splits and redistributes; C node count stays unchanged; D height increases. The unsorted first leaf [1,4,3] is reproduced literally, not silently repaired.
Select all that apply
Answer & solution
Official answer: B, D
Approach: Follow the insertion path and propagate any overflow upward. Because 23 exceeds the largest root separator, it routes to the rightmost leaf [20,21,22]. Adding it produces four keys in a node whose capacity is three. This leaf must split into two leaves under the ordinary insertion algorithm; for example its data can be distributed as [20,21] and [22,23]. A separator for the new leaf is inserted into the parent. The parent is the root and is already full with three keys. Its overflow requires an internal-node split and a new root above the split pieces. Thus the height increases by one. B and D are true, while A and C are false. The usual allocation adds one leaf, one internal node and one new root, raising five nodes to eight. the printed first leaf is unsorted, so the figure is not literally a valid B+ tree. Separator conventions also are not fully specified. The intended overflow argument uses the unaffected rightmost branch and assumes a valid initial tree apart from the diagram defect. The official B;D answer is preserved, with that limitation explicit.
A B+ tree node holds at most four keys. One root-to-leaf path is A=(49,77,83,−), B=(7,19,33,44), C=(20*,22*,25*,26*), where stars mark leaf data entries. A pointer between separators k1,k2 covers [k1,k2), and a newly created leaf copies its smallest key into its parent. Insert key 23. What is the smallest separator key in the parent of the resulting leaf that contains 25*?
Answer & solution
Official answer: 33
The insertion belongs in C because 19≤23<33. Its sorted data entries become [20*,22*,23*,25*,26*], exceeding the four-key limit, so C splits. With a 2/3 split, the leaves are [20*,22*] and [23*,25*,26*], and separator 23 is copied up. With a 3/2 split, they are [20*,22*,23*] and [25*,26*], and separator 25 is copied up. Let k be that copied separator, either 23 or 25.
B was already full. After receiving k, its ordered separators are [7,19,k,33,44], so B must split as well. For an internal-node split, the middle separator k is promoted to A rather than kept as a key in either split internal node. The left internal node retains [7,19], and the right retains [33,44]. The leaf holding 25* is on the right side of k and is a child of this right internal node.
Consequently its parent's smallest stored key is 33, even though that parent has a leftmost child whose values can be smaller than 33. A had spare capacity, so receiving k causes no further split. The unspecified 2/3 versus 3/2 leaf convention does not change the requested answer: 33.
Which file organizations are I/O-efficient for scanning all records? A sorted file; B heap file; C unclustered tree index; D unclustered hash index.
Select all that apply
Answer & solution
Official answer: A, B
Approach: Optimize for reading the entire data set, not for retrieving a few qualifying records.
1. Derivation. A full scan of a sorted file or a heap file reads the data pages sequentially, usually once each. Scanning through an unclustered index can chase record pointers to many scattered data pages, causing repeated/random I/O. Thus the I/O-efficient file organizations for the full scan are A, B; a selective index lookup is a different workload.
2. Explanation and checks. For a data file occupying B pages, scanning the file in its physical order takes about B page reads whether the records have a sorted order or an arbitrary heap order. An unclustered index does not group the data records in index traversal order, so neighboring index entries may point to different pages and cause random accesses or rereads. The index also has its own pages to read. Selectivity can make an index attractive for lookup, but that is absent in a full scan.
An ordered file has 25,000 unspanned records of 100 bytes, including a 15-byte primary key. Blocks hold 1024 bytes. A sparse primary index has one anchor key and 5-byte block pointer per data block, with unspanned entries. Binary search on b index blocks costs ceil(log2 b) accesses by stipulation. How many accesses identify the candidate data block, without reading that block?
Answer & solution
Official answer: 6
Each data block holds floor(1024/100)=10 unspanned records, so 25000 records occupy 2500 blocks. The sparse primary index has one anchor entry per data block. Each entry occupies 15+5=20 bytes, so an index block holds floor(1024/20)=51 entries and the index needs ceil(2500/51)=50 blocks. By the expressly given search-cost rule, identifying the data-block pointer costs ceil(log2 50)=6 block accesses. Reading that data block would add one more, but the question asks only to identify it.
Teaching detail. Unspanned storage requires rounding at each level before progressing. A block cannot store 10.24 records, so 24 bytes remain unused after its ten full records. Similarly an index block stores 51 complete 20-byte entries, leaving four bytes. There are 2500 data-block anchors, not 25,000 record-level entries, because the index is sparse. Since 49·51=2499, a fiftieth index block is necessary for the final anchor. With 32<50≤64, the stated ceiling-logarithm search rule yields six accesses, excluding the data fetch.
A database relation r(A,B) is stated to contain 1200 tuples. A takes integer values 6 through 20 and B values 1 through 20; A and B are independently distributed. Estimate the output count of σ[(A>10) OR (B=18)](r). The source does not explicitly assume uniform distributions and its tuple count exceeds the distinct-pair domain size.
Answer & solution
Official answer: 819 to 820 OR 205
Our answer: 820 under uniform bag estimation; official also accepts 205
Under uniform independent attribute estimates, P(A>10)=10/15 and P(B=18)=1/20. Inclusion-exclusion gives selection fraction 10/15+1/20−(10/15)(1/20)=41/60. Multiplying by 1200 gives 820. The official key also accepts 205, which is the number of distinct qualifying pairs in the full 15×20 value grid: 200 pairs with A>10 plus 5 additional pairs with B=18. Both official alternatives are preserved exactly. Premise issues: independence alone does not imply uniform marginals, and a mathematical set relation with only these two finite-domain attributes can have at most 300 distinct tuples, not 1200. The820 estimate therefore uses bag/count statistics and uniformity assumptions; 205 corresponds to the distinct-pair grid, not 1200 distinct source tuples.
There are 15 A-values and 20 B-values. Ten A-values (11 through 20) pass A>10, while one B-value passes B=18. The overlap must be subtracted because OR counts a tuple satisfying both only once. Under the full-grid model there are 10×20+15×1−10×1=205 qualifying pairs out of 300, so the selectivity is 205/300=41/60. Applying that fraction to the stated 1200 rows yields 820. These are distinct interpretations, not two different arithmetic roundings of one count.
150000 student records sorted by primary key RollNo. Secondary candidate key ANum uses 12 bytes; record pointers 7 bytes. Index records contain ANum and corresponding record pointer. Blocks are 4096 bytes and records cannot straddle blocks. Find index block count.
Answer & solution
Official answer: 698
The secondary candidate-key index is dense, with one entry per student. Each entry needs 12+7=19 bytes. With no split entries, each 4096-byte block holds floor(4096/19)=215 entries. Thus ceil(150000/215)=698 blocks.
ANum is not the ordering key of the data file, so a sparse primary index with one entry per data block is not applicable. Packing permits 215 complete 19-byte entries per block because 216 require 4104 bytes. There are 697 full blocks holding 149855 entries and 145 entries in a final block.
A B+ tree indexes one million records on a disk with 4 KB blocks. Search keys are 12 bytes and tree/disk pointers 8 bytes. Initially no index node or record is cached; each record fits in one disk block. Find the minimum disk accesses to retrieve any record in the conventional separate-record layout.
Answer & solution
Official answer: 4
Worked explanation
An internal node with m child pointers has m−1 separating keys. Its bytes are 8m+12(m−1)=20m−12, at most 4096. Thus m≤205.4 and maximum fanout is 205 (206 would require 4108 bytes). A leaf key/record-pointer pair takes 20 bytes, so it holds at most 204 pairs; adding an 8-byte next-leaf pointer still permits 204. Two index levels, root and leaves, hold at most 205×204=41820 entries and cannot cover one million. Three levels have capacity 205²×204=8573100, enough. A lookup must read one node per level, then follow the leaf’s record pointer to a separate data block. Three index reads plus one data read give four. The calculation concerns minimum height, not arbitrarily sparse trees.
Derivation and answer
With4KB=4096 bytes, an internal node with m child pointers and m−1 keys needs 8m+12(m−1)≤4096, giving maximum fanout 205. A leaf holds up to 204 key/record-pointer pairs even with one 8-byte next-leaf pointer. A root plus leaves can address at most 205*204=41820 records, below one million. Three index levels can address 205*205*204=8573100 records, so the minimum tree has three levels. With nothing cached, fetch root, internal node and leaf, then the separate record block: 4 disk accesses. This is the conventional separate-record B+ index layout; the record itself is not stored inline in the leaf.
Which statement about a B+ tree index is incorrect? A it is height-balanced; B non-leaf nodes have pointers to data records; C each node's keys are sorted; D each leaf has a pointer to the next leaf.
Your answer
Answer & solution
Official answer: B
Method: distinguish routing information in internal nodes from data entries at leaves.
1. A B+ tree keeps all leaves at the same depth, giving a balanced search height. Thus A describes the standard structure correctly. 2. An internal node contains separator keys and child-node pointers. Comparing a search key against the separators chooses the child subtree that may contain the record. Those pointers lead to more index nodes, not directly to the table's data records. 3. Data entries or record references occur at the leaves. Therefore B assigns a leaf responsibility to non-leaf nodes and is the incorrect statement. 4. Sorted keys let a node determine the correct child or locate the leaf entry, so C is correct. Linking leaves supports ordered scans and range queries without repeatedly returning to the root, so D is the usual leaf-link property; the last leaf's next pointer is null.
Result: B. This leaf-focused record organization is a key distinction between a B+ tree and a B-tree variant that may keep records in internal nodes.
B+ trees are balanced because: A all root-to-leaf path lengths equal; B those lengths differ by at most 1; C child counts of nonleaf siblings differ by at most 1; D record counts of leaves differ by at most 1.
Your answer
Answer & solution
Official answer: A
Every B+ tree leaf is at the same level. Consequently every root-to-leaf path has the same length, A. Occupancy counts may differ much more than one while still meeting the minimum/maximum occupancy constraints.
Balanced here describes tree height, not identical node fill. A root-to-leaf search examines the same number of tree levels whichever key range it follows. Option B is a weaker consequence of equality, but A states the defining stronger invariant. The intended single-choice answer should not be read as making the weaker inequality mathematically false.
A file's data-record order is the same as, or close to, the order of entries in an index. What kind of index is it? A dense; B sparse; C clustered; D unclustered.
Your answer
Answer & solution
Official answer: C
Clustering concerns how the data records themselves are arranged relative to the search key, making nearby key values physically nearby. Dense versus sparse concerns how many index entries exist, not whether the underlying file follows the key order. Therefore density alone cannot answer the question. An unclustered index may point to records scattered throughout the file.
Solution: A clustered index determines the physical ordering/grouping of the underlying data records on its search key. Thus C.
A B+ tree has root separator 9; left internal separator 5 and right internal separators 13, 17. Ordered linked leaves are[1, 3], [5, 7], [9, 11], [13, 15], [17]. Count minimum index nodes fetched, including root, for keys≥7 and<15.
Answer & solution
Official answer: 5
Search from root 9 to internal 5, then leaf[5, 7]. Follow leaf links to[9, 11] and[13, 15], stopping at 15. These are root, one internal node and three leaves: 5 index nodes. Fetches of actual record pages are outside the stated index-node count.
To find the first qualifying key 7, fetch root 9, then the internal node 5, then leaf[5, 7]. Continue using leaf sibling pointers rather than returning to the root: fetch[9, 11], then[13, 15]. The final leaf must be inspected to return 13 and discover the stopping boundary 15, which is excluded. Total distinct index nodes are 2 above-leaf nodes plus 3 leaves=5. The query asks index nodes, not how many record/data pages are subsequently read.
A B+ tree has search keys of 12 bytes, blocks of 1024 bytes, record pointers of 10 bytes, and block pointers of 8 bytes. What is the maximum number of keys that fit in each non-leaf node? Use the usual internal-node layout with one more child pointer than keys and no additional stated overhead.
Answer & solution
Official answer: 50
1. For k=50 the node uses 50·12+51·8=1008 bytes, which fits. For k=51 it needs 51·12+52·8=1028 bytes, exceeding the block. These adjacent checks establish the maximum, not just a rounded estimate.
2. An internal node with k keys has k+1 child pointers, so 12k+8(k+1)≤1024. Thus20k≤1016 and k≤50. Record pointers belong in leaves and are not counted here.
A nested-loop relational join combines r(R) and s(S), with size(r)<size(s). There are three disk-block-sized buffers, one reserved for intermediate output. Which yields fewer disk-block accesses? A r in the outer loop; B s in the outer loop; C join selectivity above 0.5; D join selectivity below 0.5.
Your answer
Answer & solution
Official answer: A
1. Set up the reasoning. With two input buffers, scan the inner relation once for each outer block. For block counts br and bs, compare br+br·bs with bs+bs·br, ignoring common output writes.
2. Derive the result. With one input-block buffer for each relation and one output buffer, block nested loops cost b_outer+b_outer·b_inner reads, excluding common output cost. The product is unchanged by swapping, but the initial outer scan is smaller when r is outer. Thus A, interpreting size as disk-block count.
3. Check the interpretation. The product cost is symmetric, but the one-time outer scan is not. The smaller block-count relation is therefore the better outer input. Selectivity can change result size but does not remove the specified nested-loop input scans.
An index is clustered if A its fields form a candidate key; B its fields include the primary key; C data records follow the same order as index data entries; D data records do not follow that order.
Your answer
Answer & solution
Official answer: C
A clustered index has its data records physically organized in the same order as the index’s data entries. This is about file ordering, not merely whether the indexed fields form a candidate or primary key. Hence C.
Clustering describes physical locality/order of the records relative to the index ordering. Scanning adjacent index entries can therefore correspond to nearby ordered records. Key uniqueness is a different property: an index can be clustered on a nonunique field, and a primary-key index need not determine the physical record order in every storage design. Thus C states the defining relationship, while A/B confuse clustering with key constraints and D describes the opposite relationship.
A sufficiently large relation r has attributes A1,...,An, with 1≤p≤n. Q1 projects A1,...,Ap after selection Ap=c. Q2 projects the same attributes after selection c1≤Ap≤c2. The database may use ordered indexing or hashing on Ap. Which statement is intended to be TRUE?
(A) Ordered indexing always outperforms hashing for both (B) Hashing always outperforms ordered indexing for both (C) Hashing outperforms ordered indexing on Q1, but not Q2 (D) Hashing outperforms ordered indexing on Q2, but not Q1
Your answer
Answer & solution
Official answer: C
Our answer: C under the standard index cost model
Q1 is equality on the indexed attribute, where a well-distributed hash index normally locates its bucket in expected constant time and outperforms ordered search. Q2 is a range predicate, for which an ordered index finds the first qualifying entry and scans the interval; hashing lacks that order. Thus C is the conventional comparison. Actual performance also depends on collisions, selectivity, caching and index layout, so this is not a universal measured-time guarantee for every database.
Hashing sends equal keys to a bucket but does not put nearby numerical values in nearby buckets. Thus an equality predicate can use one hash lookup plus collision handling, whereas a range may require examining many buckets. A sorted index can locate the lower bound and walk adjacent entries until the upper bound. Projection of columns A1,...,Ap does not change this key distinction between the selection predicates. The source's absolute performance wording is stronger than what can be guaranteed without a storage cost model.
In a B+ tree, the maximum number of keys in a node is five. What is the minimum number of keys in any nonroot node? Options: (A) 1; (B) 2; (C) 3; (D) 4.
Your answer
Answer & solution
Answer: B (no official key was published)
With at most five keys, an internal node has at most six child pointers. A nonroot internal node must have at least ceil(6/2)=3 children and therefore at least two separator keys. Such an internal node attains the minimum, giving 2, B. Under the usual leaf convention a leaf with capacity five has at least three data keys; the requested minimum over nonroot nodes is still two, not a claim that every leaf may have two.
An internal search node with c child pointers has c−1 separator keys. The maximum of five keys therefore corresponds to order six, whose half-full lower bound is three children, not three keys. The root is exempt from the ordinary minimum occupancy rule. Keeping child counts distinct from key counts avoids the common off-by-one error.
A clustering index is defined on fields of which type?
(A) Non-key and ordering (B) Non-key and non-ordering (C) Key and ordering (D) Key and non-ordering
Your answer
Answer & solution
Answer: A (no official key was published)
1. An ordering field determines the physical ordering of the data file. 2. If that field is non-key, multiple records can share a value and form a contiguous cluster, indexed by a clustering-index entry. 3. This classical classification gives A. An ordering key instead gives a primary index; a non-ordering field gives a secondary index. Modern clustered-index terminology can be broader.
A file has 16384 records of 32 bytes each, with a 6-byte key. It is ordered on a non-key field and uses unspanned organization. Block size is 1024 bytes and block pointers occupy 10 bytes. A multilevel secondary index is built on the key. How many first- and second-level index blocks are needed?
(A) 8 and 0 (B) 128 and 6 (C) 256 and 4 (D) 512 and 5
Your answer
Answer & solution
Answer: C (no official key was published)
1. Because the file is not ordered by the indexed key, the first secondary-index level is dense, with one entry per record. An entry occupies 6+10=16 bytes, so a 1024-byte block holds 64 entries. 2. The first level therefore needs 16384/64=256 blocks. The second level indexes those ordered first-level blocks, requiring 256/64=4 blocks. 3. Option C. The 512 data blocks are not the first-level index-block count.
The order of a B+ tree leaf is the maximum number of (value,data-record-pointer) pairs it can hold. Block size is 1K bytes, value size 9 bytes, record-pointer size 7 bytes and block-pointer size 6 bytes. What is the leaf order? Options: (A) 63 (B) 64 (C) 67 (D) 68
Your answer
Answer & solution
Answer: A (no official key was published)
1. Approach. Reserve space for the leaf’s next-block pointer before dividing the remaining bytes by entry size. Use 1K=1024 bytes and round the result down, because partial entries cannot be stored.
2. Derivation and interpretation. A leaf stores m pairs of 9-byte values and 7-byte record pointers, plus a 6-byte pointer to the next leaf. Therefore 16m+6 <= 1024, giving m <= floor(1018/16)=63. Answer A. Ignoring the leaf-link pointer would incorrectly give 64.
Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student, have no nulls, foreign keys or additional constraints. Amounts 6000,7000,8000,9000,10000 are each paid by 20% of students. Both plans list courses of students paying more than x. Plan 1 sequentially scans paid, selects amount>x, probes enrolled's student index for an indexed nested-loop join, then projects course. Plan 2 scans all paid and performs the same indexed join first, then selects amount>x and projects course. Projection does not request DISTINCT. A disk seek costs 4 ms, transfer rate is 300 MB/s, and checking amount>x costs 10 μs per tuple. Which statement holds? Options: (A) The plans do not return identical rows for every database (B) Plan 1 may list a course more than once (C) At x=5000 Plan 1 is faster for every database (D) At x=9000 Plan 1 is slower for every database
Your answer
Answer & solution
Answer: B (no official key was published)
1. Both plans select the same matching paid/enrolled tuples: pushing a predicate on paid.amount below the join preserves the result. Projection without DISTINCT can output the same course for two different qualifying students, so B is true under SQL bag semantics.
2. The enrolled key is (student,course), not course. C is not universal: at x=5000 all paid rows pass, and with no enrollments Plan 2 has no joined rows to test while Plan 1 still tests paid rows.
3. D is not universal either: at x=9000 Plan 1 can avoid 80% of index probes, making it faster on ordinary populated instances. Seek and transfer constants do not turn either universal performance claim into a theorem.
4. The plans/options continue on page 11.
5. Teaching check: Pushing a filter before a join can reduce work, but a universal speed claim needs more than a selectivity estimate. Course is not a key of the join output, so two qualifying students in the same course produce repeated course values after projection without DISTINCT.
Key reason to prefer B+ trees over binary search trees for database indexes? A many records; B relations sorted on primary key; C always lower memory; D disk transfers occur in blocks.
Your answer
Answer & solution
Answer: D (no official key was published)
Disk I/O transfers whole blocks. A high-fanout B+ tree packs many keys/pointers into each block, reducing tree height and therefore block reads relative to an ordinary pointer-based binary search tree. Thus D is the key storage-system reason.
The expensive unit is usually a disk block read. A B+ node can contain many separators and pointers in one block, providing much higher branching factor than a binary node. Higher branching factor reduces the number of blocks on a root-to-leaf search. Thus D identifies the storage-aware reason, not a universal claim that B+ trees use fewer bytes or require the underlying relation to be sorted.
The order of an internal B+ tree node is its maximum number of children. Child pointers use 6 bytes, search keys 14 bytes and each node occupies a 512-byte block. With no stated header overhead, what is the order? Options: (A) 24 (B) 25 (C) 26 (D) 27
Your answer
Answer & solution
Answer: C (no official key was published)
1. With order p, an internal node holds p child pointers and p−1 separator keys. The size is 6p+14(p−1)=20p−14≤512, so p≤26.3 and the maximum integer is 26.
2. At p=26 the node uses 506 bytes; p=27 would need 526 bytes. No unmentioned header overhead is assumed.
3. Teaching check: There is one fewer separator key than child pointers, so a p-child node needs p pointers and p−1 keys. Using p of each would incorrectly lower the capacity. Testing the two neighboring integers confirms maximality rather than relying only on rounded division.
Build a B⁺-tree index on STUDENT.Name. Each name occupies 8 bytes, a disk block holds 512 bytes, and an index pointer occupies 4 bytes. What is the best degree, defined as pointers per node? (A) 16; (B) 42; (C) 43; (D) 44.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Check the limiting integers explicitly.
Step 2: For43 pointers there are 42 keys, using 43×4+42×8=172+336=508 bytes, which fits 512. For44 pointers and 43 keys, storage is 176+344=520 bytes, which does not fit. Thus43 is the maximum under the stated layout;42 is unnecessarily conservative, and 16 leaves substantial unused space.
Conclusion: An internal node with m child pointers has m−1 separator keys. Its storage is 4m+8(m−1)=12m−8 bytes. Requiring this to fit 512 bytes gives m≤43⅓, so the largest integer fanout is 43, C. This uses the stated idealized node layout without extra header bytes;44 would need 520 bytes.
Original17(a): Fill Constant or Variable in four search-time cells: X1 successful B-tree, X2 unsuccessful B-tree, X3 successful B+tree, X4 unsuccessful B+tree. Constant means independent of which key is sought in a fixed tree, not asymptotically O(1); Variable means depending on that key. Successful means the key exists; unsuccessful means it is absent.
Answer & solution
Answer: X1=Variable; X2=Constant; X3=Constant; X4=Constant. (no official key was published)
Interpret search time as the number of tree levels or disk pages visited in a fixed tree, with record retrieval in a B+ tree proceeding to its leaf. A successful B-tree search may stop at the root, an internal node, or a leaf, depending on where its key resides; X1 is Variable. An unsuccessful B-tree search reaches a leaf, and all leaves have equal depth, so X2 is Constant. B+ tree records are located at leaves, so both successful and unsuccessful record searches traverse the fixed-height root-to-leaf path; X3 and X4 are Constant. Here Constant means independent of which key is searched in that tree, not O(1) as the database grows.
Why prefer B+-trees to binary trees for disk-resident databases: larger disk capacity, much slower disk access than memory, lower transfer rate alone, or greater disk reliability?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: A B+-tree node can fill a disk page and contain many keys and child pointers. Its high fanout sharply reduces the number of levels compared with a binary tree holding a similar number of keys.
Step 2: A search typically needs one page access per level, so reducing height reduces expensive random disk accesses. The latency difference between disk and memory is the decisive reason, B.
Capacity and reliability do not by themselves explain this branching-factor advantage; transfer rate is distinct from the random-access cost being minimized.
An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 6, without intermediate diagrams.
Answer & solution
Answer: Root [4]; linked leaves [1,2,3] → [4,5,6]. (no official key was published)
The requested final tree is:
[4]
/ ╲
[1 2 3] → [4 5 6]
The first five keys fit in the single root-leaf. Inserting 6 overflows its capacity to six keys, so divide its sorted entries evenly into [1,2,3] and [4,5,6]. Create an internal root with separator 4, the minimum of the right child. A search for a key below 4 chooses the left child and a search for 4 or greater chooses the right. Because this is a B+-tree, copying 4 to the parent does not remove 4 from the leaf. The arrow denotes the leaf-level successor link. The stem does not define its separator convention; a max-left convention can instead display root[3] with the same leaves. Here and in subsequent parts the minimum-of-right convention is fixed explicitly.
An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 10, without intermediate diagrams.
Answer & solution
Answer: Root [4,7]; linked leaves [1,2,3] → [4,5,6] → [7,8,9,10]. (no official key was published)
The requested tree is:
[4 | 7]
/ | ╲
[1 2 3] → [4 5 6] → [7 8 9 10]
After the first split, increasing keys always enter the rightmost leaf. That leaf fills with 4,5,6,7,8 and overflows on 9. Splitting its six keys yields [4,5,6] and [7,8,9]; copy 7 into the existing root. The root now has two separators and three child pointers, well within its five-key capacity, so it does not split. Insert 10 into the rightmost leaf to get [7,8,9,10]. The first leaf remains [1,2,3]. Separators4 and 7 remain present in their respective data leaves. Under a max-left separator convention the same leaf layout can be shown with root[3,6]; the answer above uses the stated minimum-of-right convention throughout.
An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Modify insertion: before splitting an overflowing/full target, move one value to its left sibling if that sibling exists and has room; otherwise split. Show the tree after inserting 1 through 9.
Answer & solution
Answer: Root [5]; leaves [1,2,3,4] → [5,6,7,8,9]. (no official key was published)
The final tree under the stated overflow-split convention is:
[5]
/ ╲
[1 2 3 4] → [5 6 7 8 9]
At the first overflow there is no left sibling, so the first six keys split as usual into [1,2,3] and [4,5,6]. Increasing insertions fill the right leaf through 8. To accommodate 9, that target leaf would contain [4,5,6,7,8,9], but the left sibling has spare capacity. Move its smallest key4 to the left sibling, and keep [5,6,7,8,9] on the right. Moving the smallest, rather than the largest, preserves the global leaf ordering. Update the parent separator from 4 to 5 because the right leaf’s minimum changed. No new leaf is needed. Equivalently one can redistribute4 just before inserting 9 into the full right leaf. Do not split again merely because the right leaf has five entries: five is its legal maximum; the sixth causes overflow. Separator conventions and split timing must be consistent with part(a).
A B+-tree leaf holds at most m keys. Insert a long increasing sequence using ordinary balanced splits on overflow. What is the approximate average number of keys per leaf?
Answer & solution
Answer: Approximately m/2; more precisely the frozen left split size, usually floor((m+1)/2), up to rounding and a boundary leaf. (no official key was published)
All new larger keys enter the rightmost leaf. When it overflows with m+1 keys, a balanced split leaves about half in the old left leaf and half in a new rightmost leaf. The old left leaf will never receive another key during an increasing insertion sequence. Repeating this process freezes nearly every completed leaf at its half-full split occupancy. Only the final rightmost leaf varies between its initial split size and m, and its contribution to the average vanishes as the number of leaves grows. Therefore the average is approximately m/2, not the roughly 69% occupancy sometimes quoted for random insertions. If the convention gives the left leaf floor((m+1)/2) keys, the limiting average is that integer. For m=5 and a3+3 split this is exactly 3 in the limit. Rounding and the choice of which side gets an extra key for even m explain why the question asks approximately.
A B+-tree leaf holds at most m keys. Insert a long increasing sequence, moving a key to the left sibling before splitting whenever that sibling has room. Estimate average leaf occupancy.
Answer & solution
Answer: Approximately m keys per leaf, approaching full occupancy. (no official key was published)
New keys continue to enter the rightmost leaf. Whenever it overflows, move its smallest key into its left sibling if possible. Repeated overflows progressively fill that left sibling to m entries. Only once that sibling is full must the rightmost leaf split; at that moment the earlier leaves are already full and will receive no more keys. After a split the two rightmost leaves can be partly full, but later insertions fill the older of them by redistribution. Consequently all except at most the final two leaves are full. If there are L leaves, their combined deficit from Lm keys is O(m), independent of L, so average occupancy is m−O(m/L) and tends to m as L grows. This is the improvement over ordinary splitting’s approximately half-full completed leaves for monotone input. Parent separator updates are essential for correctness but do not change the leaf occupancy calculation.
Which comparison is correct: disk versus RAM exclusivity, faster B+-tree range queries, primary versus secondary exclusivity, or height independent of record count?
Your answer
Answer & solution
Answer: B (no official key was published)
B+-trees store the data entries at the leaf level and typically link those leaves in key order. After locating a range’s first entry, scanning successive leaves retrieves the remainder efficiently without repeated searches through internal nodes. This is the conventional range-query advantage in B. Both structures may be disk resident and can support different index roles, so A and C are false dichotomies. Height still increases with record count at a fixed fanout, making D false. The comparison assumes the standard linked-leaf B+-tree layout.
Records 1–5 are Rama 27CON A, Abdul 22ENG A, Jennifer 28DOC B, Maya 32SER D, Dav 24MUS C. Index pointers are 1, 3, 2, 5, 4. Which field is sorted?
Your answer
Answer & solution
Answer: C: occupation (no official key was published)
Read occupations in pointer order: CON, DOC, ENG, MUS, SER. They are alphabetically increasing, so the index is on occupation. Ages in that order are 27, 28, 22, 24, 32 and are not sorted. Names start Rama, Jennifer, Abdul and likewise are not alphabetical; categories are A, B, A, C, D, also not ordered. Thus C is the matching field. The pointer sequence denotes record positions, not the index-key values themselves.
Signed four-digit values are stored as character strings or integers. Choose reduction 80%, 20%, 60%, 40%.
Your answer
Answer & solution
Answer: C: 60% under 5-byte text and 16-bit integer conventions (no official key was published)
A sign plus four decimal characters uses 5 bytes with one byte per character. Values from−9999 to 9999 fit in a 16-bit signed integer, using 2 bytes. The saving is 5−2=3 bytes, or 3/5·100%=60%, C. This assumes a fixed sign character and no text terminator or length metadata. A 32-bit integer would save only 20% under the same text layout, while other encodings change the comparison. Therefore the supplied result depends on the conventional storage widths rather than the numeric domain alone.
In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. With ℓ≥2 leaves, how many key entries are stored across all internal nodes?
Answer & solution
Answer: ℓ−1 internal key entries. (no official key was published)
Let I be the number of internal nodes and let kv be the number of key entries in internal node v. That node has kv+1 children, so summing all internal-node child counts counts every tree edge exactly once:
Σ_internal v (kv+1) = number of edges.
The whole tree has I+ℓ nodes and is connected and acyclic, so it has I+ℓ−1 edges. Therefore
Σ kv + I = I+ℓ−1, and hence Σ kv = ℓ−1.
This argument includes the root, whose minimum occupancy differs from other internal nodes. It does not depend on the height, branching distribution, or order d, only on the fact that every internal node has one more child than key entries.
For a root with three leaf children, there are two root keys and ℓ−1=2. If an internal node with five leaf children is inserted one level lower, its four keys and the necessary separator keys above it still obey the same identity. The result counts stored separator entries in internal nodes; it is not the number of data records in the leaves, nor a claim about the number of distinct values across the entire B+-tree. Leaf keys can have different occupancy conventions without affecting this edge-count identity.
In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. For d=4 and exactly 52 leaves, find the maximum number of internal nodes.
Answer & solution
Answer: 13 internal nodes, attainable at height 3. (no official key was published)
With 52 leaves, the total number of internal key entries is 52−1=51. If there are I internal nodes, the root uses at least one key and every other internal node uses at least d=4. Hence
1+4(I−1)≤51, so 4I≤54 and I≤13.
An upper bound alone is not enough: equal leaf depth might prevent attaining it. Here it is attainable. Build a height-3 tree as follows: Depth 0: one root with two children (one key). Depth 1: two internal nodes, each with five children (four keys each). Depth 2: ten internal nodes. Give eight of them five leaf children and two of them six leaf children. Depth 3: 8·5+2·6=52 leaves.
Every nonroot internal node has five or six children, within the permitted five-to-nine range for d=4. All leaves are at depth three. The internal-node count is 1+2+10=13, and their key total is 1+8+8·4+2·5=51, confirming the arithmetic.
Thus 13 is both an upper bound and an achievable maximum. Treating order 4 as a maximum of four children would use a different B+-tree definition and give a wrong result for the convention explicitly supplied in this paper.
In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. For h≥1, find the minimum number of leaves.
Answer & solution
Answer: 2(d+1)^(h−1). (no official key was published)
Since h≥1, the root is internal. Its minimum one key gives a minimum of two children. Every other internal node has at least d keys, hence at least d+1 children.
At depth 1 there are therefore at least 2 nodes. At depth 2 there are at least 2(d+1), and continuing to the leaf level h gives
minimum leaves = 2(d+1)h−1.
The exponent is h−1 because the first branching step is performed by the root, with minimum fan-out two; the remaining h−1 steps have minimum fan-out d+1. Multiplying by d rather than d+1 would confuse the minimum number of keys with the number of child pointers.
The bound is attainable: give the root exactly two children and every other internal node exactly d+1 children, stopping with leaves at depth h. All nonroot internal nodes then have exactly d keys, the root has exactly one, and every leaf lies at the required common depth. For h=1 the tree is a root with two leaf children, and the formula gives 2. For d=4,h=3 it gives 2·5²=50 leaves, consistent with the 52-leaf construction in the companion part. A tree of height zero is outside this subpart and would instead consist of a single leaf.
An ISAM file has 16K records of 64 bytes including a 14-byte key. A block address needs 2 bytes; disk blocks are 512 bytes. Find data blocks, index blocks, and number of index-tree levels.
Answer & solution
Answer: 2048 data blocks; 67 index blocks (64+2+1); 3 index levels, or 4 levels including data. (no official key was published)
Use K=1024, full blocks, unspanned fixed-length records, and the usual sparse ISAM index with one key-and-block-address entry per child block. Each data block holds floor(512/64)=8 records. Thus 16*1024/8=2048 data blocks are needed. The 14-byte key is already included in each 64-byte record; it must not be added again.
An index entry occupies 14+2=16 bytes, so an index block contains floor(512/16)=32 entries and can identify 32 child blocks. The lowest index level needs one entry for each of 2048 data blocks, giving ceil(2048/32)=64 index blocks. The next level indexes those 64 blocks and uses ceil(64/32)=2 blocks. A root indexes these two and fits in ceil(2/32)=1 block. Hence the total index area contains 64+2+1=67 blocks.
The hierarchy is:
root index: 1 block (2 populated entries)
-> middle index: 2 blocks (64 entries in total)
-> bottom index: 64 blocks (2048 entries in total)
-> data: 2048 blocks (16384 records).
There are three index levels, excluding the data level. If all levels including data are counted, the root-to-record path spans four levels; that is a different counting convention. The data area occupies 2048*512=1,048,576 bytes, and the allocated index area occupies 67*512=34,304 bytes, including root slack. There are 2115 blocks overall. No overflow reserve, block header overhead, or occupancy factor is supplied, so none is invented. A dense record-level index would have a different size and is not the standard sparse ISAM interpretation used here.