private void Add(TreeSortNode <T> node, TreeSortNode <T> newNode) { if (Compare(node.Data, newNode.Data) == 1) { if (node.Left == null) { node.Left = newNode; } else { Add(node.Left, newNode); } } else { if (node.Right == null) { node.Right = newNode; } else { Add(node.Right, newNode); } } }
private void Add(TreeSortNode <T> node) { if (Root == null) { Root = node; Count++; } else { Add(Root, node); Count++; } }
private List <TreeSortNode <T> > Inorder(TreeSortNode <T> node) { var list = new List <TreeSortNode <T> >(); if (node != null) { if (node.Left != null) { list.AddRange(Inorder(node.Left)); } list.Add(node); if (node.Right != null) { list.AddRange(Inorder(node.Right)); } } return(list); }
public TreeSortNode(T data, TreeSortNode <T> left, TreeSortNode <T> right) { Data = data; Left = left; Right = right; }