April 2018
Intermediate to advanced
292 pages
6h 44m
English
The next necessary class is named BinaryTree. It represents the whole binary tree. By using the generic class, you can easily specify a type of data stored in each node. The first part of the implementation of the BinaryTree class is as follows:
public class BinaryTree<T>
{
public BinaryTreeNode<T> Root { get; set; }
public int Count { get; set; }
}
The BinaryTree class contains two properties: Root, which indicates the root node (as an instance of the BinaryTreeNode class), as well as Count, which has the total number of nodes placed in the tree. Of course, these are not the only members of the class, because it can also be equipped with a set of methods regarding traversing the tree.
The first traversal method, described in this book, ...