示例#1
0
 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);
         }
     }
 }
示例#2
0
 private void Add(TreeSortNode <T> node)
 {
     if (Root == null)
     {
         Root = node;
         Count++;
     }
     else
     {
         Add(Root, node);
         Count++;
     }
 }
示例#3
0
        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);
        }
示例#4
0
 public TreeSortNode(T data, TreeSortNode <T> left, TreeSortNode <T> right)
 {
     Data  = data;
     Left  = left;
     Right = right;
 }