retagged by
3,200 views
4 votes
4 votes
Which of the following statements true for $B$ tree and $B^+$ tree index?

A. $B$ tree index faster for range queries compare to $B^+$ tree index.

B. If disk block allocated for $B^+$  tree index and same size disk block allocated for $B$ tree index then number of index blocks and I/O cost of $B^+$  tree index less than or equal to B tree index for given distinct keys.

C. If disk block allocated for $B^+$  tree index and same size disk block allocated for $B$ tree index. Then $B$ tree index access cost less than or equal to $B^+$  tree index for given distinct keys.

D. If number of keys that can store in $B$ tree and $B^+$  tree index is same then I/O cost of $B^+$  tree index less than equal to I/O cost of $B$ tree index for random access of same key from set of distinct keys.
retagged by

1 Answer

Best answer
11 votes
11 votes

Answer : B 

Let's check each Option :

Option A  : Range Queries mean  sequential access of records. Range Queries are like this :  $20 \leq P \leq 50$ Hence, Sequential Access.  And $B^+$ Trees are more suitable for  sequential access of records since they have All the keys at the bottom level as well while each Bottom level Node pointing to the next bottom level node. Hence, Option A is False.

Option D : Correction in Option D... " If number of keys that can store in B tree and B+ tree index node is same"

You have already asked a Question completely based on Option D before. Refer here : https://gateoverflow.in/216456/b-tree  

In this above link, I had stopped at "Order is same  is One Basis of Comparison between B and $B^+$ Tress. There are other situations in which you would get better results for BTree Like When the Node/Block Size is same etc." Now, Let's see How.

Option B and C :  If disk block allocated for B+ tree index is same size as disk block allocated for B tree index then We can put more number of keys in $B^+$ tree node as Unlike B tree, We do not need to store Record pointers along with every key in $B^+$ tree node. So, Because of not having to store Record pointers in the Internal nodes in $B^+$ tree, We get less number of levels in $B^+$ tree index for large number of keys than B tree index. Hence,  number of index blocks and I/O cost of B+ tree index less than or equal to B tree index for given distinct keys.


Let's keep it simple. You know that whatever is the Situation/basis of comparison between B and B+ trees..... The Performance will depend on "Number of Levels". So, Now what we have to do it check the Number of levels in both tress (But for Large number of keys...As happens in practical life)

1. When Disk Block Size is same :

Disk block means Node. So, Node size is same. So, We have advantage in B+ tree because In B+ tree we do not need to store Record pointers in the internal nodes, Hence we can store More number of keys in One node. Which leads to less number of levels. 

Now, You must be thinking that in B+ tree, we have All the Internal keys repeated at bottom level as well which is not the case in B tree and which might bring disadvantage to B+ tree. Yes, It will surely bring disadvantage to B+ tree But that would not have much impact when large number of keys are stored. Let me explain How!!

Take a case and analyze. Will give your more intuition about it. Either take some Previous GATE question data or consider this..Say, Block size is 1024 Bits, Key size is 10 bits, Pointer size (Record and Node pointer both) = 6 bits.. Now, Try and see. Apply this data for both B+ tree and B tree, Because it is given that here Block size is same (Not tht Order is same) You will find that Because we don't need to store record pointers in the internal nodes in B+ tree, You can store 63 Keys per internal node whereas in B tree you can only store 43 keys per internal node. That's huge difference when large number of keys will be stored. Even if you have to repeat all the internal keys in the bottom level, You would have less number of levels in B+ tree than in B tree.

Practically also, This same thing happens. Disk Block size is same and we have advantage in B+ tree.


2 .When Order is same :

Here also Disk block size is same but it's effect/advantage on B+ tree is finished because We have to keep the Order same. Now, We cannot store more number of keys in One node in B+ tree. So, Here the fact that Keys repeat in B+ tree brings disadvantage to B+ tree.

Refer my answer here : https://gateoverflow.in/216456/b-tree

selected by

Related questions

2 votes
2 votes
1 answer
1
skywalker_19 asked Oct 8, 2018
672 views
How to prove that if same size blocks are allocated to B trees and B+ trees then:-No. of index nodes in B tree >= No. Of index nodes in B+ tree
0 votes
0 votes
1 answer
2
iarnav asked Dec 15, 2017
1,403 views
Does values in Leaf nodes of B+ tree repeats or ever leaf node has an unique value?
6 votes
6 votes
1 answer
4
Habibkhan asked Oct 19, 2016
1,106 views
Q : One basic doubt that is coming to my mind is whether number of splits in the process of insertion in B+ Tree indexing going to change if we consider left biasing and ...