using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Convention { namespace NTree { public class NTreeNode { public NTreeNode Parent; public NTreeNode Child; public NTreeNode Right; public T Data; public int BranchSize() { if (Parent == null) return -1; var left = Parent.Child; int result = 0; while (left != null) result++; return result; } public int BranchLeftCount() { if (Parent == null) return -1; var left = Parent.Child; int result = 0; while (left != this) result++; return result; } public int BranchRightSize() { var left = this; int result = 0; while (left != null) result++; return result; } } public class NTree { internal NTreeNode Root; public bool IsEmpty() => Root == null; public NTreeNode UpdateRoot(NTreeNode node) { var oldRoot = Root; Root = node; return oldRoot; } } } }