Chapter 3 File Organization Trees Structures
Chapter 3 File Organization Trees Structures
• Introduction
• B-Trees
• Conclusion
Introduction
• Index table methods are limited to certain types of files (small files or
static files). Methods based on tree structures are better suited for
large and/or dynamic files. To better utilize block space, m-ary trees
are employed.
M-ary Search Trees
• An m-ary search tree of order n is a tree where each node can have at
• Node b is the first child of a, and f is the fifth child of a. An internal node
may have some children set to nil while others are not. For instance, all
children of b except the third one are set to nil. Similarly, the first, third,
and fourth children of node d are set to nil, while its second child (pointing
to h) and fifth child (pointing to i) are not nil.
Note
• The general structure of a block is as follows:
• End
• Among the characteristics of a file viewed as a tree, there is the root.
It is the block number containing the root of the tree. For example, if
the tree in the previous figure were a file, the content of block d
would be as follows:
Val 42 50 55 60 5 Val 10 2
• If P is not full,
➢insert V into P, shifting elements to keep the array of values ordered. Else (P is
full):
➢allocate a new node Q containing a single value (Val[1] = V) and two children set
to nil (Children[1] = nil and Children[2] = nil).
➢make the Children[k] of P point to the new node Q (which was, before the
insertion, necessarily nil). The index k is the one returned by the search.
• For example, if we insert the value 64 into the tree from the previous
figure, we proceed as follows:
1. Search for 64 → failure (the last visited node is i, and the position
where 64 should be inserted is k=2).
2. Since the node i is not full, we can insert 64 at position 2 by shifting
to the right the values > 64.
• If we insert the value 62, we will allocate a new node (j) that contains
62, and it will be pointed to by the Children[1] of node i (where i is the
last visited node in the search for 62, and the position where 62 should
be inserted in i, if there were space, is k = 1).
B-Trees
• These are m-ary search trees that always remain balanced and are
therefore very useful for managing large and dynamic files. For
simplicity, an odd order is chosen (N = 2d+1). In a B-Tree of order N:
• All nodes except the root are filled at least 50% (i.e., d values).
• When the root of a B-Tree splits (due to an insertion), the depth of the tree
increases by one level.
Conclusion
In conclusion, tree methods