RED BLACK TREE & TRIES
SEARCH STRUCTURES
Red Black Tree click here
Red Black Tree Algorithm click here
Tries click here
Red-Black Properties
- Every node is either red or black.
- Every leaf (NULL pointer) is black.
■ Note: this means every “real” node has 2 children - If a node is red, both children are black
■ Note: can’t have 2 consecutive reds on a path - Every path from node to descendent leaf contains the same number of black nodes.
- The root is always black
RB Trees: Worst-Case Time
- So we’ve proved that a red-black tree has O(lg n) height
- Corollary: These operations take O(lg n) time:
■Minimum(), Maximum()
■Successor(), Predecessor()
■Search()
■Successor(), Predecessor()
■Search()
- Insert() and Delete():
■But will need special care since they modify tree
Comments
Post a Comment