DBMS
DBMS
REVANTH REDDY
ID : 21BTCSE020
COURSE : B.TEC.CSE
SUBJECT : DATA BASE MANAGEMENT
SYSTEM
SUB CODE : CSIT - 524
SUBMITTED TO : DR.S.K.YADAV
SUBMITTED BY : P.REVANTH
REDDY
DATA BASE
MANAGEMENT
SYSTEM
PPT ON B-TREE
WHAT IS B-TREE…?
very node has at most m children where m is the order of the B-Tree.
node with K children contains K-1 keys.
very non-leaf node except the root node must have at least ⌈m/2⌉ child nodes.
he root must have at least 2 children if it is not the leaf node too.
ll leaves of a B-Tree stays at the same level.
nlike other trees, its height increases upwards towards the root, and insertion happens at the leaf node.
he time complexity of all the operations of a B-Tree is O(log n), here ‘n’ is the number of elements in the B-
EXAMPLE OF A B-TREE OF ORDER 4
WHAT IS A B+ TREE?
B-Trees are characterized by the large number of keys that they can store
in a single node, which is why they are also known as “large key” trees.
Each node in a B-Tree can contain multiple keys, which allows the tree to
have a larger branching factor and thus a shallower height. This shallow
height leads to less disk I/O, which results in faster search and insertion
operations. B-Trees are particularly well suited for storage systems that
have slow, bulky data access such as hard drives, flash memory, and CD-
ROMs.
B-Trees maintain balance by ensuring that each node has a minimum
number of keys, so the tree is always balanced. This balance guarantees
that the time complexity for operations such as insertion, deletion, and
searching is always O(log n), regardless of the initial shape of the tree.
PORPERTIES OF B-TREE
•All leaves are at the same level.
•B-Tree is defined by the term minimum degree ‘t‘. The value of ‘t‘
depends upon disk block size.
•Every node except the root must contain at most t-1 keys. The root may
contain a minimum of 1 key.
•All nodes (including root) may contain at most (2*t – 1) keys.
•Number of children of a node is equal to the number of keys in it plus 1.
•All keys of a node are sorted in increasing order. The child between two
keys k1 and k2 contains all keys in the range from k1 and k2.
•B-Tree grows and shrinks from the root which is unlike Binary Search
Tree. Binary Search Trees grow downward and also shrink from
downward.
•Like other balanced Binary Search Trees, the time complexity to search,
insert and delete is O(log n).
•Insertion of a Node in B-Tree happens only at Leaf Node.
TRAVERSAL IN B-TREE
Traversal in B-Tree:
Traversal is also similar to Inorder traversal of Binary Tree. We start from the leftmost child,
recursively print the leftmost child, then repeat the same process for the remaining children
and keys. In the end, recursively print the rightmost child.
SEARCH OPERATIONS IN B-TREE
Search is similar to the search in Binary Search Tree. Let the key to be searched is
k.
•Start from the root and recursively traverse down.
•For every visited non-leaf node,
• If the node has the key, we simply return the node.
• Otherwise, we recur down to the appropriate child (The child which is just
before the first greater key) of the node.
•If we reach a leaf node and don’t find k in the leaf node, then return NULL.
Searching a B-Tree is similar to searching a binary tree. The algorithm is similar and
goes with recursion. At each level, the search is optimized as if the key value is not
present in the range of the parent then the key is present in another branch. As
these values limit the search they are also known as limiting values or separation
values. If we reach a leaf node and don’t find the desired key then it will display
NULL.
APPLICATIONS OF B-TREE