You are on page 1of 3

COS 212 Tutorial 5

• 22/03/2018
• Total of 13 marks.

Name and Surname:

Student/Staff Nr:

Instructions

1. This tutorial must be completed individually.


2. You are allowed to make use of any material.
3. Answer all of the questions in the space provided.
4. Be sure to hand in your completed sheet at the end of the tutorial class.

Page 1 of 3
COS 212 Tutorial 5: 22/03/2018

Question 1 B-Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (8 marks)


1.1 What is the maximum number of keys that can be contained in a B-tree of height 8 with M = 5? (1)

Solution:

1.2 Consider the B-tree in figure 1. Delete the key 56 from this tree and draw as your answer only the final tree (3)
after this deletion.

Solution:

50

61 69 74 85
10 20

30 31 32 55 60

11 12 62 63

1 2 70 71 72 73

79 80 82 83

89 90 92

1 mark for each circled node that’s correct

Page 2 of 3
COS 212 Tutorial 5: 22/03/2018

50

60 69 74 85
10 20

30 31 32 55 56

11 12 61 62 63

1 2 70 71 72 73

79 80 82 83

89 90 92

Figure 1: B-Tree

1.3 Consider the B-tree in figure 1. Delete the key 2 from this tree and draw as your answer only the final tree (4)
after this deletion.

Solution:

60

69 74 85
20 50

55 56

30 31 32 61 62 63

1 10 11 12 70 71 72 73

79 80 82 83

89 90 92

1 mark for each circled node that’s correct

Question 2 B* -Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (5 marks)


2.1 One advantage of B* -trees is that, other than B-trees, expensive splitting operations are delayed. Mention (2)
and briefly discuss one other advantage that B* -trees offer over B-trees.

Solution: B-Trees can be 1/2 empty, B* -trees utilize space better in that the nodes are required to be
at least 2/3 full (thus space is utilized more optimally).

2.2 In a B* -tree the following restriction is given: Only the root node is allowed to underflow and all other nodes (3)
must be at least b 2m−1
3 c full at any time. Under this restriction, special care needs to be taken when dealing
with root splits. Firstly, name a problem that could potentially arise in the case of a root split and secondly,
discuss a strategy to prevent this problem from occuring.

Solution: If the root is the same size as the other nodes, then there will only be enough keys to ensure
that the children of the new root are 50% full after the root splits, leading to them underflowing. (1
Mark)
Suggestion: Maintain a root that is larger than the other nodes in the tree. Make sure that if the root
splits, there will be enough keys so that each of the new root’s children can get b 2m−1
3 c keys, and there
Page 3 of 3
is a separator key for the new root. (2 marks)

You might also like