In a past exam we were once asked to decide whether a tree was red-black balanced by looking at its shape. I haven't found any information on how to do this, except that one sight claims that a binary tree is red-black balanced if the longest path is no more than twice the shortest, but I'm pretty sure that's the requirement for null path balanced trees, too. Is that correct? Is there any way to tell if a tree is red-black balanced by the shape?
I'm not guru, but this is from Cormen's book Introduction to Algorithms
:
A red-black tree is a binary tree that satisfies the following red-black properties:
- Every node is either red or black.
- The root is black.
- Every leaf (NIL) is black.
- If a node is red, then both its children are black.
- For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With