An intuition is that red-black trees encode 2-3-4 trees (B-trees of order 4) as binary trees.
For a simpler case, 2-3 trees (Ie. B-trees of order 3) are either empty, a (2-)node with 1 value and 2 subtrees, or a (3-)node with 2 values and 3 subtrees. The idea is to insert new values in their sorted position, expand 2-nodes to 3-nodes if necessary, and bubble up the extra values when a 3-node should be expanded. This keeps the tree balanced.
A 2-3-4 tree just generalises the above.
Now the intuition is that red means “I am part of a bigger node.” That is, red nodes represent the values contained in some higher black node. If the black node represents a 2-node, it has no red children. If it represents a 3-node, it has one red child, and if it represents a 4-node, it has 2 red children.
In this context, the “rules” of the red-black trees make complete sense. For instance we only count black trees when comparing branch heights because those represent the actual nodes. I’m sure that with a bit of work, it’s possible to make complete sense of the insertion/deletion rules through the B-tree lens but I haven’t done it.
edit: I went through the insertion rules and they do make complete sense if you think about a B-tree while you read them.
An intuition is that red-black trees encode 2-3-4 trees (B-trees of order 4) as binary trees.
For a simpler case, 2-3 trees (Ie. B-trees of order 3) are either empty, a (2-)node with 1 value and 2 subtrees, or a (3-)node with 2 values and 3 subtrees. The idea is to insert new values in their sorted position, expand 2-nodes to 3-nodes if necessary, and bubble up the extra values when a 3-node should be expanded. This keeps the tree balanced.
A 2-3-4 tree just generalises the above.
Now the intuition is that red means “I am part of a bigger node.” That is, red nodes represent the values contained in some higher black node. If the black node represents a 2-node, it has no red children. If it represents a 3-node, it has one red child, and if it represents a 4-node, it has 2 red children.
In this context, the “rules” of the red-black trees make complete sense. For instance we only count black trees when comparing branch heights because those represent the actual nodes. I’m sure that with a bit of work, it’s possible to make complete sense of the insertion/deletion rules through the B-tree lens but I haven’t done it.
edit: I went through the insertion rules and they do make complete sense if you think about a B-tree while you read them.