Reputation: 77
While I was studying Search Trees, I found a problem
Show that the nodes of any AVL tree T can be colored "red" and "black" so that T becomes a red-black tree.
And now I wonder whether converting any AVL tree to red black tree is possible.
Upvotes: 1
Views: 732
Reputation: 5093
Yes, it is possible.
General idea is to turn red some of nodes that are roots of subtrees of odd height. More specifically, we turn red only those whose parents are root of subtrees of even height. You can prove that using recursion.
Upvotes: 1