diff --git a/C#/Datastructures/BinarySearchTree/Tree.cs b/C#/Datastructures/BinarySearchTree/Tree.cs new file mode 100644 index 0000000..98eadfe --- /dev/null +++ b/C#/Datastructures/BinarySearchTree/Tree.cs @@ -0,0 +1,25 @@ +using C_.Datastructures.BinarySearchTree; +using System; + +namespace C_.Datastructures.BinarySearchTree +{ + internal class Tree where T:IComparable + { + public TreeNode? Head { get; set; } + public int Count { get; set; } + + public Tree Create(){ + //Create a new Tree with no Head + return new Tree{ + Head = null, + Count = 0 + }; + } + public Tree Create(T? value){ + //Create a new Tree with Head + return new Tree{ + Head = TreeNode.Create(value) + }; + } + } +} \ No newline at end of file diff --git a/C#/Datastructures/BinarySearchTree/TreeNode.cs b/C#/Datastructures/BinarySearchTree/TreeNode.cs new file mode 100644 index 0000000..dba7e08 --- /dev/null +++ b/C#/Datastructures/BinarySearchTree/TreeNode.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using C_.Datastructures.Generic; + +namespace C_.Datastructures.BinarySearchTree +{ + internal class TreeNode:DirectedNode> + { + //All properties inherited from base class + public static TreeNode Create(T? value){ + //Create a new node without any children + return new TreeNode{ + Value = value + }; + } + + public static TreeNode Create(T? value, TreeNode? left, TreeNode? right){ + //Create a new node with the option of having children + return new TreeNode{ + Value = value, + Left = left, + Right = right + }; + } + } +} \ No newline at end of file