Lably
Skip to content

2–3 tree

Data structure in computer science

  • 4 min read
  • 3 chapters

Related on Lably

Through Computer science

2–3 trees are required to be balanced, meaning that each leaf is at the same level. It follows that each right, center, and left subtree of a node contains the same or close to the same amount of data.

Definitions

We say that an internal node is a 2-node if it has one data element and two children.

We say that an internal node is a 3-node if it has two data elements and three children.

A 4-node, with three data elements, may be temporarily created during manipulation of the tree but is never persistently stored in the tree.

We say that T is a 2–3 tree if and only if one of the following statements hold:

  • T is empty. In other words, T does not have any nodes.
  • T is a 2-node with data element a. If T has left child p and right child q, then
    • p and q are 2–3 trees of the same height;
    • a is greater than each element in p; and
    • a is less than each data element in q.
  • T is a 3-node with data elements a and b, where a < b. If T has left child p, middle child q, and right child r, then
    • p, q, and r are 2–3 trees of equal height;
    • a is greater than each data element in p and less than each data element in q; and
    • b is greater than each data element in q and less than each data element in r.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication