in Databases edited by
16,039 views
46 votes
46 votes

Consider the $B^+$ tree in the adjoining figure, where each node has at most two keys and three links.

Keys $K15$ and then $K25$ are inserted into this tree in that order. Exactly how many of the following nodes (disregarding the links) will be present in the tree after the two insertions?

  1. $1$
  2. $2$
  3. $3$
  4. $4$
in Databases edited by
16.0k views

2 Comments

3
3
Do you have the actual question paper. Can you please share it. Its no where available in the web. Moreover there are many mistakes while copying the questions in websites like solutionsadda, geeksforgeeeks etc. Pls Pls...
0
0

5 Answers

61 votes
61 votes
Best answer

Option (A) is correct.

It is a $B^+$ Tree.

After inserting $K15$ we get

 

Now, we insert $K25$, which gives -

So, we see in the final tree only $\text{(K20, K25)}$ is present. Hence, 1 (Ans).

edited by

4 Comments

I know the way to insert in b+ tree is that first we're going to insert k15 as the left child of k30 & as it's become more than its Max size it can occupy so shifting middle element i.e, k15 only to.the upper level & when at second time k25 is to be inserted  it'll just inserted to the near by of k20 . Is it wrong???

0
0
edited by
What if we use redistribution policy??
0
0

I am new to this concept. Here's my attempt.  Can anyone please tell me if this is the right tree structure after insertion

0
0
12 votes
12 votes
Answer: A

Only one node will be there, i.e. (K 20,K 25). After inserting K 15, the node (K 10, K 20) splits and K 15 moves up to form (K 15,K 30).

After K 25 is inserted, K20 moves up to the root  & splits up (K15,K30) &  it forms (K 20,K 25).

So, after final insertion only (K20,K25) present.  So, 1 is the answer.

2 Comments

i am getting (15,20).... where did you insert 25 ...?

pls explain little bit more ...
0
0
@Sonam, see the selected answer.
0
0
1 vote
1 vote
I am not adding complete answer but just adding some useful points

In B+ tree unlike B tree in case of overflow we keep value in leaf as well as promote value to parent node

For intermediate nodes operation is same for both B and B++ i..e promote value to parent node don't keep value in child node

In case of left Biasing : when in case of overflow no of keys are odd , take middle key with left sibling

In case of right Biasing : when in case of overflow no of keys are odd , take middle key with right sibling

follow only one biasing for all splits in tree , dont change method in between.  hence answer is (20,25) in either left biasing or right one.

1 comment

@mehul vaidya can you give some reference for left and right biasing because as of now it doesn't seem correct as well as in textbook(Korth) clearly given when right bias and when keys are odd or even then first key(which is smallest from right) taken as a root

1
1
0 votes
0 votes
Caption

[K20,K25] present. Therefore, option A.

 

Answer:

Related questions