DataStructuresCSharp/Datastructures/BinaryTree/TreeNode.cs

28 lines
810 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using C_.Datastructures.Generic;
namespace C_.Datastructures.BinaryTree
{
internal class TreeNode<T> : DirectedNode<T, TreeNode<T>>
{
//All properties inherited from base class
public static TreeNode<T> Create(T value){
//Create a new node without any children
return new TreeNode<T>{
Value = value
};
}
public static TreeNode<T> Create(T value, TreeNode<T>? left, TreeNode<T>? right){
//Create a new node with the option of having children
return new TreeNode<T>{
Value = value,
Left = left,
Right = right
};
}
}
}