In this post we will compare Red Black Tree and AVL Tree.
Red Black Tree:
- Self-Balancing is provided by painting each node with one two colors(Red or Black).
- When Tree is modified, new tree is subsequently rearranged and repainted.
- It requires 1 bit of color information for each node in tree.
Constraints maintained by Red Black Tree:
- Root is always black.
- All NULL leaves are black, both children of red node are black.
- Every simple path from a given node to any of its descendant leaves contains the same number of black
- Path form root to farthest leaf is no more than twice as long as path from root to nearest leaf.
AVL(Adelson-Velskii and Landis) Tree
- Height difference of left and right subtree of node should be less than 2.
- Re-balancing is done when heights of two child subtrees of a node differ by more than one.
- Faster retrievals as strictly balanced.
- AVL trees provide faster lookups than Red Black Trees because they are more strictly balanced.
- Red Black Trees provide faster insertion and removal operations than AVL trees as fewer rotations are done due to relatively relaxed balancing.
- AVL trees store balance factors or heights with each node, thus requires storage for an integer per node whereas Red Black Tree requires only 1 bit of information per node.
- Red Black Trees are used in most of the language libraries like map, multimap, multiset in C++ whereas AVL trees are used in databases where faster retrievals are required.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if a given Binary Tree is height balanced like a Red-Black Tree
- Red-Black Tree | Set 2 (Insert)
- Red-Black Tree | Set 3 (Delete)
- Red-Black Tree | Set 1 (Introduction)
- C Program for Red Black Tree Insertion
- Left Leaning Red Black Tree (Insertion)
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Difference between General tree and Binary tree
- Difference between Binary tree and B-tree
- Difference between B tree and B+ tree
- Binary Tree to Binary Search Tree Conversion
- Binary Tree to Binary Search Tree Conversion using STL set
- Difference between Binary Tree and Binary Search Tree
- Tree Sort
- AVL Tree | Set 1 (Insertion)
- AVL Tree | Set 2 (Deletion)
- Introduction of B-Tree
- BST to a Tree with sum of all smaller keys
- Difference between graph and tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.