April 2018
Intermediate to advanced
292 pages
6h 44m
English
As in the case of AVL trees, let's prepare the example for RBTs, using the external library. The simple program will show how to create a new tree, add elements, remove a particular node, and benefit from other features of the library.
Let's take a look at the following fragments of the code, which should be added to the Main method in the Program class. The first part is as follows:
RedBlackTreeList<int> tree = new RedBlackTreeList<int>();
for (int i = 1; i <= 10; i++)
{
tree.Add(i);
}
Here, a new instance of the RedBlackTreeList class is created. It is indicated that the nodes will store integer values. Then, the for loop is used to add 10 numbers (ordered from 1 to 10) to the tree, using the Add method. ...