Questions tagged [red-black-tree]

A red-black tree is a type of self-balancing binary search tree, a data structure used in computing science, typically used to implement associative arrays.

From Wikipedia, Red–black tree:

A red-black tree is a special type of binary tree, used in computer science to organize pieces of comparable data, such as text fragments or numbers.

The leaf nodes of red-black trees do not contain data. These leaves need not be explicit in computer memory — a null child pointer can encode the fact that this child is a leaf — but it simplifies some algorithms for operating on red-black trees if the leaves really are explicit nodes. To save memory, sometimes a single sentinel node performs the role of all leaf nodes; all references from internal nodes to leaf nodes then point to the sentinel node.

Red-black trees, like all binary search trees, allow efficient in-order traversal in the fashion, Left-Root-Right, of their elements. The search-time results from the traversal from root to leaf, and therefore a balanced tree, having the least possible tree height, results in O(log n) search time.

588 questions
-3
votes
1 answer

What is an intuitive explanation of rotation in red-black trees?

Quoting from CLRS When we do a left rotation on a node x, we assume that its right child y is not T.nil; x may be any node in the tree whose right child is not T.nil. The left rotation “pivots” around the link from x to y. It makes y the new root of…
TruckDriver
  • 1,383
  • 13
  • 28
-5
votes
1 answer

AVL and Red-Black Trees

I do not know how to do either of these problems. However, I did find example code for the AVL tree here: http://users.cis.fiu.edu/~weiss/dsaajava/code/DataStructures/AvlTree.java However, I still am unsure how to do this. Can someone please help me…
1 2 3
39
40