Identity the valid red black tree
Answers
Answer:
Properties of a red-black tree
Each tree node is colored either red or black.
The root node of the tree is always black.
Every path from the root to any of the leaf nodes must have the same number of black nodes.
No two red nodes can be adjacent, i.e., a red node cannot be the parent or the child of another red node.
Explanation:
A red-black tree is a Binary tree where a particular node has color as an extra attribute, either red or black. By check the node colors on any simple path from the root to a leaf, red-black trees secure that no such path is higher than twice as long as any other so that the tree is generally balanced.
red-black tree is a binary search tree which has the following red-black properties:
Every node is either red or black.
Every leaf (NULL) is black.
If a node is red, then both its children are black.
Every simple path from a node to a descendant leaf contains the same number of black nodes