Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Add 2-3-4 Tree Implementation #45

Open Kalkwst opened 1 year ago

Kalkwst commented 1 year ago

A 2-3-4 tree is a type of self-balancing tree data structure that is used to efficiently store and retrieve data. It is similar to a 2-3 tree, but each node can have up to 4 keys and 5 children, which allows for more efficient storage and retrieval of data by reducing the number of nodes that need to be traversed to locate the data.

From a more technical perspective, a 2-3-4 tree is a self-balancing tree data structure that is similar to a 2-3 tree. Each node in the tree can have up to 4 keys and 5 children, which allows for more efficient storage and retrieval of data by reducing the number of nodes that need to be traversed to locate the data. The tree is organized in such a way that each node has either three children (if it has one or two keys) or four children (if it has three keys). This allows for efficient search, insertion, and deletion operations, as the tree can be traversed starting from the root node to reach the desired node in logarithmic time complexity O(log n) where n is the number of nodes in the tree. Additionally, the tree is balanced by ensuring that the number of nodes in the left and right subtrees of any node is roughly equal, which ensures that the time complexity of the operations remains logarithmic as well. The 2-3-4 tree is an extension of the 2-3 tree, which allows the tree to hold more keys per node, therefore it improves the space utilization and reduces the number of nodes in the tree which results in fewer disk accesses and faster search, insertion and deletion.