Algorithms-DataStructures/BinaryTree/node.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2021-11-18 17:40:29 +00:00
namespace BinaryTree
{
public class node
{
public dynamic Data { get; set; }
private node Parent { get; set; }
private node Left { get; set; }
private node Right { get; set; }
//Print Method Data
public int StartPos;
public int Size { get { return Data.Length; } }
public int EndPos { get { return StartPos + Size; } set { StartPos = value - Size; } }
2021-11-18 18:07:13 +00:00
public node(dynamic data = null,
node parent = null,
node left = null,
node right = null){
2021-11-18 17:40:29 +00:00
//New node for a Binary Tree. Values can be set to null if they are not present
2021-11-18 18:07:13 +00:00
Data = data;
Parent = parent;
Left = left;
Right = right;
2021-11-18 17:40:29 +00:00
}
public node GetParent(){
return Parent;
}
2021-11-18 18:07:13 +00:00
public void SetParent(node parent){
Parent = parent;
2021-11-18 17:40:29 +00:00
}
public node GetLeft(){
return Left;
}
2021-11-18 18:07:13 +00:00
public void SetLeft(node left){
Left = left;
2021-11-18 17:40:29 +00:00
}
public node GetRight(){
return Right;
}
2021-11-18 18:07:13 +00:00
public void SetRight(node right){
Right = right;
2021-11-18 17:40:29 +00:00
}
}
2021-06-21 11:56:26 +00:00
}