0% found this document useful (0 votes)
4 views12 pages

2 3 Tree Presentation

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)
4 views12 pages

2 3 Tree Presentation

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/ 12

2-3 Tree

Implementation
BY:
S.HAAJRAFATHIMA
S.HEMALATHA
L.SRI BHARATHI
VARIANCE OF 1,2,3 TREES IN THEIR STRUCTURE:
Objective:
 Implement a 2-3 Tree in C++ as part
of the mini project.
 Focus on the following operations:
 Insertion: Maintaining balance
through node splitting.
 Search: Efficiently locating keys.
 Display: Traversal to showcase the
tree structure.
What is a 2-3 Tree?

 A 2-3 Tree is a balanced search tree


where:
 2-node: Contains 1 key and 2 children.
 3-node: Contains 2 keys and 3 children.
 Ensures logarithmic time complexity for
search, insertion, and deletion.
Why Choose a 2-3 Tree?

 Self-balancing: The tree stays balanced,


preventing skewed structures.
 O(log n) time complexity for operations.
 All leaf nodes are at the same level,
ensuring uniform depth.
 Easier to implement compared to Red-
Black or AVL trees.
Insertion Process

 Locate the position where the new key


should be inserted.
 If the node has space, insert the key.
 If the node overflows, split the node and
move the middle key up.
 Repeat the process upwards if necessary.
Insertion Example with Splitting

 Insert keys: 5, 10, 15, 20, 25.


 Afterinserting 15, the tree remains
balanced.
 Inserting
20 causes a split, and 20
moves up.
 The tree is adjusted with new nodes
for 15 and 25.
Search Operation

 Start at the root node and compare the key


with node keys.
 Traverse left or right based on comparison
results.
 Repeat until the key is found or a leaf is
reached.
Display Operation

 In-ordertraversal visits nodes in


sorted order.
 Recursively traverse the left subtree,
visit the current node, and traverse
the right subtree.
Applications of 2-3 Tree

 Practical Applications:
 Database indexing for efficient
searches.
 Filesystems for managing large
datasets.
 Balancedsearch algorithms and
memory management.
Conclusion

 Summary of the Project:


 The 2-3 Tree ensures balance and
efficiency.
 Demonstrated key operations:
insertion, search, and display.
 Readyfor practical applications in
databases and file systems.

You might also like