Skip to Content
C# Data Structures and Algorithms
book

C# Data Structures and Algorithms

by Marcin Jamro
April 2018
Intermediate to advanced content levelIntermediate to advanced
292 pages
6h 44m
English
Packt Publishing
Content preview from C# Data Structures and Algorithms

Tree

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, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Data Structures and Algorithms in C#

Beginning Data Structures and Algorithms in C#

Marcin Jamro

Publisher Resources

ISBN: 9781788833738Supplemental Content