c++ - red black tree insert implementation - what is a sentinel? -


I have received this code and it has a constructor for a red black node

  RedBlackTree :: RedBlackTree () {blue = new RedBlackTreeNode; Zero-> Left = nil-> Correct = zero-> Parent = zero; Zero-> Red = 0; Zero-> Key = MIN_INT; Nil- & gt; Archived Entry = Null; Root = new RedBlackTreeNode; Root- & gt; Parents = Root-> Left root = & gt; True = zero; Root- & gt; Key = MAX_INT; Root- & gt; Red = 0; Root- & gt; Archived = Null; }  

What is zero and why is it started in the constructor? Can I just declare zero nodes in my personal data field and start it in my inclusive function?

This is basically a place holder.

The code is used for README: / * For a watchman origin and for zero it becomes watchdog, when redbluectricity is calmed. Root-> Left should always point to the node, which is the root of the tree. Zero points to a node which is always black, but for this there is no thankful children and parents and no keys or information. The point of using these sensors is that the root and zero nodes do not require special cases in the code. * /

From Wikipedia

1. A node is either red or black

2. The root is black (This rule is sometimes left) Since the root can always change from red to black, but not necessarily, the analysis of this rule has a bearing on it. .)

3. All the cards (zero) black. (All the leaves are the same color as the root.)

4. Every red node should have two black hair nodes.

5. Each path of each of your offspring from any node leaves the same number of black nodes in the leaves.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -