- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

A 2-3 Tree is a type of tree in data structures in which every node of the tree is either a 2 node

or 3 nodes. It is a special type of **B-Tree** with order 3.

A 2 node in the tree is one which has one data part and two child nodes.

A 3 node in the tree is one which has two data parts and three child nodes.

Every internal node is either a 2 node or a 3 node.

A node containing one data part can be a 2 node with exactly 2 children or a leaf node with no children.

A node containing two data parts can only be a 3 node with exactly 3 children.

All leaf nodes are always at the same level.

A 2-3 tree is always a height balanced tree.

Search operations are fast and efficient in a 2-3 tree.

Exactly two children.

Left child with smaller weight.

Right child with greater weight.

Can be a leaf node with no child.

Exactly three children.

2 data values.

Left child with weight smaller than left data value.

Middle child with weight in between both data values.

Right child with weight greater than right data value.

Can never be a leaf node.

Similar to the search operation in a binary search tree as the data is sorted.

To search X in a 2-3 tree.

If tree is empty → return False

If we reach root node then return False (not found)

If X is less than the left data part, then search the left subtree

If X is greater than left data and more than right data, search the middle subtree.

If X is greater than the right data part, then search right subtree.

To insert X in a 2-3 tree.

If the tree is empty → Add X as root.

Search for the right position of X and add it as a leaf node.

If there is a leaf node with one data part, add X with and leaf node becomes 2 - Node.

If the leaf node has two data parts, add X. Split temporary 3-nodes and move data to parent nodes according to the sorting order.

Make 2-3 tree and add nodes in order → 10, 5, 8, 15, 23, 21

To delete X in a 2-3 tree.

If the tree is empty return false.

Search for the position of X and delete it, then adjust the tree.

If X is part of 3 node delete X and adjust left value and middle value. Also adjust node’s ancestor’s left and middle value if necessary.

If X is part of 2 node then adjust and split the tree in a recursive manner arranging nodes in sorted order.

- Related Questions & Answers
- 2-3 Trees (Search and Insert) in C/C++?
- Binary Trees and Properties in Data Structures
- Binary Search Trees in Data Structures
- Optimal Binary Search Trees in Data Structures
- Tournament Trees, Winner Trees and Loser Trees in Data Structure
- Data objects and Structures
- Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + .. + n in C++
- Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n) in C++
- Inbuilt Data Structures in C#
- C++ Programe to find n-th term in series 1 2 2 3 3 3 4
- Difference between C structures and C++ structures
- Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n - 1)^2 in C++
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2) in C++
- What are JavaScript data types and data structures?
- Count number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. in C++

Advertisements