Thursday, 21 November 2013

Red Black Tree

Red-black tree is a Binary search tree that has each node is colored either red or black.
Properties of red black tree:
1. This is the same as for binary search trees: all the keys
     to left of a node are smaller, and a to the right of a node are
     larger than the node key
2.The number of black nodes on every path from the root
     to each leaf is the same.  This is called as the black height of the tree.
3. No two consecutive nodes are red.
Red Black Tree
Red Black Tree

 Red Black tree ensure that the longest path from the root to a leaf is at most twice as long as the shortest path.  Since insertion and searching  in a binary search tree have time proportional to the length of
the path from the root to the leaf, this is sure that O(log(n)) times for these
operations, even if the  red black tree is not perfectly balanced.

Related Posts:

  • String In C The string in C programming language is a one-dimensional array of characters which is terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by… Read More
  • Scope Rules In C A scope in any program is a that region of the program where a defined variable can have its existence and beyond that variable can't be accessed. The three places where variables can be declared in C programming l… Read More
  • C language 'C' is a well known programming language which was developed by Dennis  Ritchie  in 1972 in  AT&T Bell Labs. This programming language was influenced by B , BCPL ,  ALGOL, and some other programming… Read More
  • Decision Making Structure In C Decision making structures allows the programmer to specify one or more conditions to be evaluated or tested by the compiler or , along with a statement or set of statements to be executed if the condition is  … Read More
  • Storage Classes in c A storage class in C defines the scope (visibility) and life-time of a variables and/or a functions .These specifiers precede the type that they modify. There are some storage classes, which are  used in a C Pr… Read More

0 comments:

Post a Comment