2022-04-04 20:36:04 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using C_.Datastructures.Generic;
|
|
|
|
|
2022-04-14 16:26:06 +00:00
|
|
|
namespace C_.Datastructures.BinaryTree
|
2022-04-04 20:36:04 +00:00
|
|
|
{
|
2022-04-10 21:27:56 +00:00
|
|
|
internal class TreeNode<T> : DirectedNode<T, TreeNode<T>>
|
2022-04-04 20:36:04 +00:00
|
|
|
{
|
|
|
|
//All properties inherited from base class
|
2022-04-13 20:17:33 +00:00
|
|
|
public static TreeNode<T> Create(T value){
|
2022-04-04 20:36:04 +00:00
|
|
|
//Create a new node without any children
|
|
|
|
return new TreeNode<T>{
|
|
|
|
Value = value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-13 20:17:33 +00:00
|
|
|
public static TreeNode<T> Create(T value, TreeNode<T>? left, TreeNode<T>? right){
|
2022-04-04 20:36:04 +00:00
|
|
|
//Create a new node with the option of having children
|
|
|
|
return new TreeNode<T>{
|
|
|
|
Value = value,
|
|
|
|
Left = left,
|
|
|
|
Right = right
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|