Top MCQs on B and B+ Trees with Answers

  • Last Updated : 27 Sep, 2023

B-Tree is known as a self-balancing tree as its nodes are sorted in the inorder traversal.
B+ tree eliminates the drawback B-tree used for indexing by storing data pointers only at the leaf nodes of the tree.
More on B and B+ Trees

B and B+ tree Quiz

B and B+ tree Quiz


Question 1

Consider a B+-tree in which the maximum number of keys in a node is 5. What is the minimum number of keys in any non-root node? (GATE CS 2010)

Cross

1

Cross

2

Cross

3

Tick

4



Question 1-Explanation: 

Since the maximum number of keys is 5, maximum number of children a node can have is 6. Bydefinition of B Tree, minimum children that a node can have would be 6/2 = 3. Therefore, minimum number of keys that a node can have becomes 2 (3-1)=4.

Question 2
Which one of the following is a key factor for preferring B-trees to binary search trees for indexing database relations?
Cross
Database relations have a large number of records
Cross
Database relations are sorted on the primary key
Cross
B-trees require less memory than binary search trees
Tick
Data transfer form disks is in blocks.


Question 2-Explanation: 
A disk block contains fairly large number of keys. Unlike BST where each node contains only one key, B-Tree is designed to contain large number of keys so that tree height is small.
Question 3
B+ trees are preferred to binary trees in databases because (GATE CS 2000)
Cross
Disk capacities are greater than memory capacities
Tick
Disk access is much slower than memory access
Cross
Disk data transfer rates are much less than memory data transfer rates
Cross
Disks are more reliable than memory


Question 3-Explanation: 
Disk access is slow and  B+ Tree provide search in less number of disk hits. This is primarily because unlike binary search trees, B+ trees have very high fanout (typically on the order of 100 or more), which reduces the number of I/O operations required to find an element in the tree.
Question 4
Which of the following is FALSE about B/B+ tree
Cross
B/B+ trees grow upward while Binary Search Trees grow downward.
Tick
Time complexity of search operation in B/B+ tree is better than Red Black Trees in general.
Cross
Number of child pointers in a B/B+ tree node is always equals to number of keys in it plus one.
Cross
A B/B+ tree is defined by a term minimum degree. And minimum degree depends on hard disk block size, key and address sizes.


Question 4-Explanation: 
Asymptotic time complexity of both is of order logn.
Question 5

A B-tree of order 4 is built from scratch by 10 successive insertions. What is the maximum number of node splitting operations that may take place?

Cross

3

Cross

4

Tick

5

Cross

6



Question 5-Explanation: 
Insertion of 3 keys
10 20 30

Insertion of 4th key (1st split)
     30
   /   \
10*20   40


Insertion of 5th key no split 
To maximize splits, let us insert a value in a node that has
key in access. Let us insert 5
      30
   /     \
5*10*20   40


Insertion of 6th key (2nd Split)
To maximize splits, let us insert a value in a node that has
key in access. Let us insert 8
      8*30
   /   |   \
5    10*20   40 


Insertion of 7th key
To maximize splits, let us insert a value in a node that has
key in access. Let us insert 15
        8*30
   /     |    \
5    10*15*20   40 



Insertion of 8th key (3rd Split)
To maximize splits, let us insert a value in a node that has
key in access. Let us insert 12
      8*12*30
   /   /   \  \
 5   10 15*20  40 


Insertion of 9th key 
To maximize splits, let us insert a value in a node that has
key in access. Let us insert 17
      8*12*30
   /  /   \   \
5  10 15*17*20 40 

Insertion of 10th key (4th and 5th Splits)
To maximize splits, let us insert a value in a node that has
key in access. Let us insert 13
          12
       /      \
      8       15*30
   /   \     /  |  \  
  5    10  13 17*20   40 
Question 6
The order of a leaf node in a tree B+ ? is the maximum number of (value, data record pointer) pairs it can hold. Given that the block size is 1K bytes, data record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer is 6 bytes long, what is the order of the leaf node?
Tick
63
Cross
64
Cross
67
Cross
68


Question 6-Explanation: 
  Disk Block size = 1024 bytes
  
  Data Record Pointer size, r = 7 bytes
  Value size, V = 9 bytes
  Disk Block ptr, P = 6 bytes 
Let order of leaf be m. A leaf node in B+ tree contains at most m record pointers, at most m values, and one disk block pointer.r*m + V*m + p <= 1024 16m <= 1018 m =< 63
Question 7
The order of an internal node in a B+ tree index is the maximum number of children it can have. Suppose that a child pointer takes 6 bytes, the search field value takes 14 bytes, and the block size is 512 bytes. What is the order of the internal node?
Cross
24
Cross
25
Tick
26
Cross
27


Question 7-Explanation: 

Key size = 14 bytes (given) Child pointer = 6 bytes (given)
We assume the order of B+ tree to be ‘n’.
Block size = (n - 1) * key size + n * child pointer 512 >= (n - 1) * 14 + n * 6 512 >= 14 * n – 14 + 6 * n n = (512 + 14) / 20 n = 526 / 20 n = 26.3 n = 26
 
Thus, option (C) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 8
Consider the following 2-3-4 tree (i.e., B-tree with a minimum degree of two) in which each data item is a letter. The usual alphabetical ordering of letters is used in constructing the tree. GATECS2003Q65 What is the result of inserting G in the above tree ?
A) GATECS2003Q65A

B) GATECS2003Q65B

C) GATECS2003Q65C

D) None of the above
Cross
A
Tick
B
Cross
C
Cross
D


Question 8-Explanation: 
Since the given B tree is 2-3-4 tree, there can be at-most 4 children or 3 keys. In B Tree insertion, we start from root and traverse till the leaf node where key is to be inserted. While traversing, if we find a a node which full, we split it. When we insert G, we find root itself is full, so we split it. When we come down to leftmost leaf, we find that the leaf is also full, so we split the leaf also.
Question 9

A B+ -tree index is to be built on the Name attribute of the relation STUDENT. Assume that all student names are of length 8 bytes, disk block are size 512 bytes, and index pointers are of size 4 bytes. Given this scenario, what would be the best choice of the degree (i.e. the number of pointers per node) of the B+ -tree?

Cross

16

Cross

42

Tick

43

Cross

44



Question 9-Explanation: 
Size of 1 record = 8 + 4 = 12

Let the order be N.

No. of index values per block = N - 1

(N - 1) 12 + 4 = 512

12N - 12 + 4 = 512

12N - 8 = 512

12N = 520

N = 520/12

N = 43.333
Question 10
With reference to the B+ tree index of order 1 shown below, the minimum number of nodes (including the root node) that must be fetched in order to satisfy the following query: “Get all records with a search key greater than or equal to 7 and less than 15” is ________ Q12
Cross
4
Tick
5
Cross
6
Cross
7


Question 10-Explanation: 
We can get all values in range from 7 to 59 by accessing 5 nodes.  
1) First search 7 in a leaf node.
2) Once 7 is found, linearly traverse till 15 is found.

See following diagram 
Q12-300x101
12
There are 16 questions to complete.