Lect8 - B-Trees 1 B-trees: Why? Best tree discussed so far...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
1 B-Trees
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 B-trees: Why? Best tree discussed so far – AVL Tree: Important operation Findkey () can be implemented in O(log n) time. AVL Tree has problems for large data the size of the AVL tree increases and may not fit in the system’s main memory. the height of the AVL tree also increases – Findkey() operation no more efficient.
Background image of page 2
3 B-trees: Why? To overcome these problems, m-way trees have been created. M-way tree allows: Each node to have at the most m children (or sub-trees) Each non-leaf node has (k-1 ) keys if it has k children. M-way tree is ordered and could be balanced like an AVL tree
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 An m-way Tree E K P B D G R S T M N Z X Y M-way tree of order 4
Background image of page 4
5 B-trees: Why? Because in a m-way tree, a node can have more than two children and more than one data element in it, the overall size (i.e. number of nodes) decreases height decreases. Also, at any time only a part of the tree can be loaded into the main memory – the rest of the tree can remain in disk storage. B-trees are a kind of m-way trees. B+-trees are special types of B-trees. Database files are represented as B-trees.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 B+ Tree : Properties B+ Tree of order M has following properties: Root is either a leaf or has 2 to M children. Non-leaf nodes (except the root) have M/2 to M children which means they can have from M/2 -1 to M-1 keys stored in them. All leaves are at the same depth or level Data elements are stored in the leaves only and have between M/2 and M data elements.
Background image of page 6
7 B+ Tree : Properties Non-leaf nodes store at the most M-1 keys to guide search; key i represents the smallest key in the subtree i + 1. Note : 1. Actually leaf nodes can have up to L data elements. To simplify we assume L is equal to M. 2. Choice of parameters L and M depends on the data being stored in the B+-tree.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 B+ Tree : Example 1 21 72 48 12 15 59 25 41 31 84 91 1,4,8,11 91,92,99 12,13 15,18,19 48,49,50 21,24 25,26 31,38 41,43,46 59,68 72,78 84,88 B+ Tree of Order 4 i.e. M=4
Background image of page 8
9 B+ Tree : Example 2 22: _ 16: _ 41: 58 8, 11, 12 16, 17 22, 23, 31 41, 52 58, 59, 61 B+ Tree of Order 3 This is how we shall draw a B+ Tree: non-leaf nodes as ovals and leaf nodes as rectangles.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 B+ Tree : Search How is FindKey operation performed in a B+- Tree? Almost as in a BST– the keys in the non-leaf
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/18/2010 for the course COMPUTER S CSC212 taught by Professor Shah during the Winter '09 term at King Saud University.

Page1 / 59

Lect8 - B-Trees 1 B-trees: Why? Best tree discussed so far...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online