示例#1
0
        public void SuccessorAndPredecessorTest()
        {
            tree.AddRange(new Node <int>[] { item });
            var suc = tree.Successor();

            var pred = tree.Predecessor();

            Assert.AreEqual(tree.GetMin(tree.root.Right), suc);
            Assert.AreEqual(tree.GetMax(tree.root.Left), pred);
        }
示例#2
0
        public void SetUp()
        {
            item      = new Node <int>(7);
            item1     = new Node <int>(4);
            item2     = new Node <int>(5);
            item3     = new Node <int>(71);
            item4     = new Node <int>(50);
            tree      = new BSTree <int>();
            tree.root = new Node <int>(15, new Node <int>(6), new Node <int>(23));

            tree.Insert(item);
            tree.Insert(item2);
            tree.Insert(item3);
            tree.Insert(item4);
            tree.Insert(item1);
            tree.Insert(new Node <int>(1));
            tree.Insert(new Node <int>(77));
            tree.AddRange(new Node <int>[] {
                new Node <int>(76), new Node <int>(75), new Node <int>(74), new Node <int>(98), new Node <int>(99),
                new Node <int>(43), new Node <int>(44), new Node <int>(51), new Node <int>(59), new Node <int>(60)
            });
            tree.Insert(null);
        }