<1> Some properties
<2> The B-tree Rule
eq.
<3> The set ADT using B-tres structure
size_t data_count; Item data[MAXIMUM +1]; size_t child_count Set *subset[MAXIMUM +2]; //here we use the property | Note :
MINIMUM, MAXIMUM are class constants eq. static const size_t MINIMUM = 20; static const size_t MAXIMUM = 2 * MAXIMUM ; |
| every child of the root is also the root of a smaller B-Tree |
--->recursion |
|
from 0 to data_count - 1 |
![]() |
find 10 in the B-tree ?
^^^^target
Approach : function bool contain(Item target)
if ( target == data[i] )
return true
else if ( the root has no children )
return false
else
return subset[i] -> contains(target);
ex1. insert 18
ex2.
Note :
eq.

Algorithm :
since the above proceure is implemented recursively
one can have the following algorithm.
loose_insent (entry) ; (*)
if (data_count > MAXIMUM)
fix_excess (data_count); (**)
(*) loose insection function (private)
template
void Set- :: loose_insert(coust Item& entry){
find the min index i such that data[i] >= entry
if (no such i ) {
i = data_corst;
}
if (data[i] == entry)
return; // nothing need to be done
else if (root has no children)
insert the entry as i-th position of data
else{
subset[i] -> loose_insert (entry); // go to thesubset
fix_excess (i);
}
(**) fix excess function (fix the excess data for the subset node)
template
void Set- :: fix_excess (size_t i ) ;
where i is the index of subset[i] for the corrent node.
HW.how to implement fix_excess?
Note :
When B-tree become large, one has to store
some of nodes of B-tree in the secondary memory.
This situation is called external B-tree.