0% found this document useful (0 votes)
22 views17 pages

DBMS

Uploaded by

21btcse016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views17 pages

DBMS

Uploaded by

21btcse016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

NAME : P.

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…?

B Tree is a self-balancing tree data structure. It


stores and maintains data in a sorted form where
the left children of the root are smaller than the
root and the right children are larger than the root
in value. It makes searching efficient and allows all
operations in logarithmic time. It allows nodes with
more than two children. B-tree is used for
implementing multilevel indexing. Every node of
the B-tree stores the key-value along with the data
pointer pointing to the block in the disk file
containing that key.
PROPERTIES OF B-TREE DBMS

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?

(1) A B+ tree is similar to a B-tree, the only difference is that their


leaves are linked at the bottom.
(2) Unlike B-tree, the nodes of the B+ tree do not store keys along
with the pointers to the disk block.
(3)The internal nodes contain only keys and the leaf nodes contain the
keys along with the data pointers.
(4) All the internal nodes are present at the leaves and are linked
together and can be traversed just like a linked list.
B+ tree also removes one drawback of using B-tree. The
internal nodes of the B-tree also store keys along with data
pointers which take more space and significantly reduce the
number of keys that can be stored at a node of the B-tree. Due
to this the number of levels increases and searching time also
increases. Unlike this, the B+ tree can store more keys than the
B-tree of the same level because of their feature of storing
pointers only at the leaf nodes. This contributes to storing more
entries at fewer levels in the B+ tree and lessens the searching
time for a key. This makes the B+ tree very efficient and very
quick in accessing the data from the disks.
EXAMPLE OF B+TREE
DIFFERENCES BETWEEN B-TREE AND
B+ TREE
B-Tree B+ Tree
Only leaf nodes contain data pointers
All internal nodes and leaf nodes contain
along with keys, internal nodes contain
data pointers along with keys.
keys only.
Duplicate keys are present in this, all
There are no duplicate keys.
internal nodes are also present at leaves.
Leaf nodes are not linked to each other. Leaf nodes are linked to each other.
All nodes are present at leaves, so
Sequential access of nodes is not
sequential access is possible just like a
possible.
linked list.
Searching for a key is slower. Searching is faster.
For a particular number of entries, the The height of the B+ tree is lesser than B-
height of the B-tree is larger. tree for the same number of entries.
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

•It is used in large databases to access data stored on the


disk
•Searching for data in a data set can be achieved in
significantly less time using the B-Tree
•With the indexing feature, multilevel indexing can be
achieved.
•Most of the servers also use the B-tree approach.
•B-Trees are used in CAD systems to organize and search
geometric data.
•B-Trees are also used in other areas such as natural language
processing, computer networks, and cryptography.
ADVANTAGES OF B-TREE

• B-Trees have a guaranteed time complexity of


O(log n) for basic operations like insertion,
deletion, and searching, which makes them
suitable for large data sets and real-time
applications.
• B-Trees are self-balancing.
•High-concurrency and high-throughput.
•Efficient storage utilization.
DISADVANTAGES OF B-TREE

• B-Trees are based on disk-based data structures and can


have a high disk usage.
•Not the best for all cases.
•Slow in comparison to other data structures
THANK YOU…..

You might also like