Red Black Tree vs AVL Tree

In this post we will compare Red Black Tree and AVL Tree.

Red Black Tree:

Red Black Tree

Properties:

  1. Self-Balancing is provided by painting each node with one two colors(Red or Black).
  2. When Tree is modified, new tree is subsequently rearranged and repainted.
  3. It requires 1 bit of color information for each node in tree.

Constraints maintained by Red Black Tree:

  1. Root is always black.
  2. All NULL leaves are black, both children of red node are black.
  3. Every simple path from a given node to any of its descendant leaves contains the same number of black
    nodes.
  4. 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

Properties:

  1. Height difference of left and right subtree of node should be less than 2.
  2. Re-balancing is done when heights of two child subtrees of a node differ by more than one.
  3. Faster retrievals as strictly balanced.

Difference:

  1. AVL trees provide faster lookups than Red Black Trees because they are more strictly balanced.
  2. Red Black Trees provide faster insertion and removal operations than AVL trees as fewer rotations are done due to relatively relaxed balancing.
  3. 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.
  4. 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.


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.