Red-Black Tree | Set 1 (Introduction) Red-Black Tree is a self-balancing Binary Search Tree (BST) where every node follows following rules. 1) Every node has a color either red or black. 2) Root of tree is always black. 3) There are no two adjacent red nodes (A red node cannot have a red parent or red child). 4) Every path from root to a NULL node has same number of black nodes. Why Red-Black Trees? Most of the BST operations (e.g., search, max, min, insert, delete.. etc) take O(h) time where h is the height of the BST. The cost of these operations may become O(n) for a skewed Binary tree.
Read full article from Red-Black Tree | Set 1 (Introduction) | GeeksforGeeks
No comments:
Post a Comment