是否可以将所有的AVL树都转换为红黑树?

Is it possible to convert all AVL trees to red-black trees?

我在研究搜索树的时候,发现了一个问题

Show that the nodes of any AVL tree T can be colored "red" and "black" so that T becomes a red-black tree.

现在我想知道是否可以将任何 AVL 树转换为红黑树。

是的,有可能。

一般的想法是将一些节点变成红色,这些节点是奇数高度的子树的根。 更具体地说,我们只将那些 parents 是偶数高度子树的根的树变红。你可以证明使用递归。