GATE GUIDE

B+ Tree and Indexing Questions in GATE CSE: Order, Levels, Accesses

By MD ANISH AHAMADUpdated 4 Nov 20268 min read
B+ Tree and Indexing Questions in GATE CSE: Order, Levels, Accesses

B+ tree questions in GATE CSE come in a small number of fixed shapes. You are given a block size, a key size and pointer sizes and asked how many keys fit in a node, how many levels a file of N records needs, or how many block accesses a lookup costs. Around those sit shorter items on dense and sparse indexes, B tree versus B+ tree properties, and the result of a sequence of insertions. The arithmetic is easy. The marks are lost on definitions.

In this guide
  1. Key takeaways
  2. Where indexing sits in the paper
  3. The order convention, settled first
  4. Worked example: capacity, levels and accesses
  5. Primary, clustering and secondary indexes
  6. B tree versus B+ tree
  7. Insertion and splits
  8. The traps in one list
  9. How to practise

Key takeaways

Where indexing sits in the paper

The official 2027 CS syllabus lists "File organization, indexing (e.g., B and B+ trees)" in the Databases section. It is the only place the DBMS syllabus names a concrete example, which is one reason the topic scores well in any priority ranking.

Third-party analyst compilations put DBMS at 3 to 11 marks per paper from 2009 to 2026, settling at 7 to 8 marks in most papers since 2019. By the analyst reconstruction used here, some B+ tree item (capacity, height, insertion or a property statement) appears in roughly half to four fifths of papers. The capacity template is placed in 2010, 2015 Set 1 and 2020, with approximate placements earlier and in 2025. A disk-access count appears in 2020, a range query over the leaf chain in 2015 Set 2, and index-type definitions in 2011, 2013 and 2015 Set 2. These years are approximate reconstructions, not official data, and analysts differ by a mark or two on classification. Check the current notification for the pattern that applies to your year.

The rest of the subject is covered in the DBMS important topics guide.

The order convention, settled first

Before any arithmetic, decide what "order" means in the question you are reading. The standard textbooks do not agree.

Source convention What the number pp means Keys in an internal node
Silberschatz, Korth and Sudarshan Maximum pointers (children) per node At most p−1p - 1
Elmasri and Navathe pp for internal nodes; a separate pleafp_{\text{leaf}} for leaf pairs At most p−1p - 1
Knuth, for B trees Maximum children At most p−1p - 1
Cormen (minimum degree tt) Minimum children of a non-root node Between t−1t - 1 and 2t−12t - 1
Some older texts Maximum keys per node At most pp

This guide uses the maximum-children convention, the one the formulas above assume. But GATE setters usually state the rule in full, for example "an internal node with nn child pointers holds n−1n - 1 keys", and when they do, that sentence wins. If a question gives only "order 5" and nothing else, read the options: one of them usually corresponds to each reading, which tells you the setter's intent.

Worked example: capacity, levels and accesses

These numbers are chosen for this guide. Block size 2048 bytes, search key 12 bytes, block pointer 6 bytes, record pointer 10 bytes.

Internal node

6p+12(p−1)≤204818p≤2060p≤114.4\begin{aligned} 6p + 12(p - 1) &\le 2048 \\ 18p &\le 2060 \\ p &\le 114.4 \end{aligned}

Take p=114p = 114 children and 113 keys. Check: 114×6+113×12=684+1356=2040114 \times 6 + 113 \times 12 = 684 + 1356 = 2040 bytes, which fits. With 115 children the node needs 115×6+114×12=2058115 \times 6 + 114 \times 12 = 2058 bytes, which does not.

Leaf node

(12+10) k+6≤204822k≤2042k≤92.8\begin{aligned} (12 + 10)\,k + 6 &\le 2048 \\ 22k &\le 2042 \\ k &\le 92.8 \end{aligned}

Take k=92k = 92 keys, each with a record pointer, plus one pointer to the next leaf. Check: 92×22+6=203092 \times 22 + 6 = 2030 bytes. The common slip is to reuse 114 or 113 for the leaf. Leaves hold record pointers, which are a different size here, and they hold only one tree pointer.

Minimum occupancy

A non-root internal node needs at least ⌈114/2⌉=57\lceil 114/2 \rceil = 57 children, so 56 keys. A leaf needs at least ⌈92/2⌉=46\lceil 92/2 \rceil = 46 keys. The root is exempt: it needs only 2 children if it is internal.

Levels for one million records

Nodes as full as possible:

leaves=⌈1,000,00092⌉=10,870parents=⌈10,870114⌉=96\begin{aligned} \text{leaves} &= \left\lceil \frac{1{,}000{,}000}{92} \right\rceil = 10{,}870 \\ \text{parents} &= \left\lceil \frac{10{,}870}{114} \right\rceil = 96 \end{aligned}

and 96 pointers fit in one root. That is 3 levels, so a point lookup costs 3 index block accesses plus 1 data block, which is 3+1=43 + 1 = 4.

Worst case, every node at its minimum (a root with 2 children, internal nodes with 57, leaves with 46 keys):

4 levels:2×57×57×46=298,908 records at least5 levels:2×57×57×57×46=17,037,756 records at least\begin{aligned} \text{4 levels:}\quad &2 \times 57 \times 57 \times 46 = 298{,}908 \text{ records at least} \\ \text{5 levels:}\quad &2 \times 57 \times 57 \times 57 \times 46 = 17{,}037{,}756 \text{ records at least} \end{aligned}

One million lies between the two, so the tree can reach 4 levels but not 5. The same file costs 4 accesses in the best case and 5 in the worst. Read whether the question says "as full as possible" or "in the worst case"; the answer depends on it.

The two formulas belong on your formula sheet next to the normal form checks.

Primary, clustering and secondary indexes

Index-type items are usually 1 mark and definitional, but a sizing variant turns them into a NAT. Three facts do most of the work.

Take a file of 60,000 records of 100 bytes in 2048-byte blocks, sorted on its key, with index entries of 12+6=1812 + 6 = 18 bytes. Data blocking factor ⌊2048/100⌋=20\lfloor 2048/100 \rfloor = 20, so 60,000/20=3,00060{,}000 / 20 = 3{,}000 data blocks. Index blocking factor ⌊2048/18⌋=113\lfloor 2048/18 \rfloor = 113.

Access path Index blocks Block accesses for one record
Binary search on the sorted data file none ⌈log⁡23000⌉=12\lceil \log_2 3000 \rceil = 12
Sparse primary index, binary searched ⌈3000/113⌉=27\lceil 3000/113 \rceil = 27 ⌈log⁡227⌉+1=6\lceil \log_2 27 \rceil + 1 = 6
Dense secondary index on a key field, binary searched ⌈60000/113⌉=531\lceil 60000/113 \rceil = 531 ⌈log⁡2531⌉+1=11\lceil \log_2 531 \rceil + 1 = 11
Multilevel on the sparse index (27→127 \to 1) 27+1=2827 + 1 = 28 2+1=32 + 1 = 3
Multilevel on the dense index (531→5→1531 \to 5 \to 1) 531+5+1=537531 + 5 + 1 = 537 3+1=43 + 1 = 4

The pattern to notice: the dense index is about 20 times larger because it holds an entry per record rather than per block, yet going multilevel costs it only one extra access.

B tree versus B+ tree

Property statements from 2016 Set 1 and 2019 were built from exactly these differences.

Property B tree B+ tree
Where data pointers live Every node Leaves only
Keys in internal nodes Each key appears once Separators, repeated in leaves
Leaf chain No Yes, leaves are linked
Range query Tree traversal Find first leaf, then follow the chain
Fan-out for a given block Lower, nodes also store data pointers Higher, internal nodes store only tree pointers
All leaves at the same depth Yes Yes

Higher fan-out is why B+ trees are shallower on the same block size. One subtle statement setters like: an internal separator in a B+ tree need not match any key currently in a leaf, because deleting a leaf key does not require deleting its copy above.

Insertion and splits

Take a B+ tree whose nodes hold at most 3 keys, and insert 10, 20, 30, 40, 50, 60 in that order. The first three fill one leaf. Key 40 overflows it to four keys, so it splits into [10, 20] and [30, 40], and 30 is copied up into a new root. Keys 50 and 60 go to the right leaf, which overflows at 60 into [30, 40] and [50, 60], and 50 is copied up. The root is now [30, 50] over three leaves: two splits, four nodes, two levels.

The rule to hold on to: a leaf split copies the separator up and keeps it in the leaf, while an internal split pushes the middle key up and removes it from below. On an even split, the question says which side takes the extra key. Insertion drawings were last confidently placed in 2016 (approximate) and are on the book's list of topics due after a gap.

The traps in one list

The same arithmetic discipline matters in the SQL row-count questions, and the cross-subject version of this list is in common mistakes that cost marks in GATE CSE.

How to practise

Pick three block sizes and two key and pointer combinations, and for each compute internal capacity, leaf capacity, minimum occupancy and best and worst levels for one million records. Always write the byte check that confirms the answer fits. Then insert a sequence of eight keys into a tree with at most 3 keys per node and count the splits. The Databases chapter of the GATE CSE 2027 book works through every B+ tree and indexing variant in its question bank with the full arithmetic, including range queries over the leaf chain and deletion with borrow and merge, which this guide only names.

Frequently asked questions

How do you calculate the order of a B+ tree in GATE?

For an internal node with pp child pointers and p−1p - 1 keys, solve p×block pointer+(p−1)×key≤block sizep \times \text{block pointer} + (p - 1) \times \text{key} \le \text{block size} for pp and take the floor. For a leaf, solve k×(key+record pointer)k \times (\text{key} + \text{record pointer}), plus one sibling pointer, within the block. Always check whether the question calls pp the maximum children or the maximum keys.

What is the minimum number of keys in a B+ tree node?

Using the maximum-children convention with order pp, a non-root internal node has at least ⌈p/2⌉\lceil p/2 \rceil children, so one fewer keys. A leaf holding at most kk keys must hold at least ⌈k/2⌉\lceil k/2 \rceil. The root is the exception. It needs only two children if it is internal, and a root that is also a leaf may hold a single key.

What is the difference between a B tree and a B+ tree?

In a B tree every key appears once, and internal nodes carry data pointers, so a search can stop above the leaf level. In a B+ tree all data pointers sit in the leaves, internal keys act only as separators and are repeated in the leaves, and the leaves are linked in a chain. That chain is what makes range queries cheap in a B+ tree.

Why must a secondary index be dense?

A sparse index stores one entry per data block and relies on the file being sorted on the indexed field, so that a scan inside the located block finds the record. A secondary index is built on a field the file is not ordered by, so matching records can sit in any block. Every value therefore needs its own entry, which makes the index dense.

How many block accesses does a B+ tree search need?

A point lookup reads one node per level from the root down to the leaf, then one more block to fetch the record through the record pointer. A tree with three levels therefore costs four block accesses when nothing is cached. Questions that say the root is kept in memory reduce this by one, so read that condition before you add anything up.

Sources

Dates, fees and the syllabus are set by the GATE 2027 organising institute and can change. Always confirm at gate2027.iitm.ac.in.

Keep reading

GATE CSE 2027 book1,020 pages · ₹250 ₹300
Buy now — ₹250