Red-black trees are defined to have the following invariants:
- The nodes are in sorted order (it is a binary search tree).
- The root is black, and leaves are black.
- Every red node has black children.
- Every path to the root passes through the same number of black nodes.
There is also an obvious "empty" operation (just a leaf) and a more involved "insert" operation described on wikipedia, as well as an erase operation, and with some effort one can show that these operations preserve the red-black invariants just described.
My question is about the converse. Is it the case that:
- Every tree satisfying the red-black invariants is reachable by applying
inserttoemptywith an appropriately chosen order of operations. - Every tree satisfying the red-black invariants is reachable by applying
insertorerasetoemptywith an appropriately chosen order of operations.
My guess is that the answer to 1 is "no" and the answer to 2 is "yes", but I have no proof of either case.