Exemple #1
0
        public BineryTree(T value, BineryTree <T> leftChild, BineryTree <T> rightChild)
        {
            if (value == null)
            {
                throw new ArgumentNullException("Cannot insert null values!");
            }

            BineryTreeNode <T> leftChildNode  = leftChild != null ? leftChild.root : null;
            BineryTreeNode <T> rightChildNode = rightChild != null ? rightChild.root : null;

            this.root = new BineryTreeNode <T>(value, leftChildNode, rightChildNode);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            BineryTree <int> tree = new BineryTree <int>(14,
                                                         new BineryTree <int>(19,
                                                                              new BineryTree <int>(23),
                                                                              new BineryTree <int>(6,
                                                                                                   new BineryTree <int>(10),
                                                                                                   new BineryTree <int>(21))),
                                                         new BineryTree <int>(15,
                                                                              new BineryTree <int>(3),
                                                                              null)
                                                         );

            tree.PrintInorder();
        }