コード例 #1
0
        public void FindSecondLargest()
        {
            BinarySearchTree tree = new BinarySearchTree();
            tree.Add(new Node { Value = 10 });
            tree.Add(new Node { Value = 5 });
            tree.Add(new Node { Value = 15 });
            tree.Add(new Node { Value = 4 });
            tree.Add(new Node { Value = 13 });

            int result = tree.FindSecondLargest();

            Assert.AreEqual(13, result);
        }
コード例 #2
0
        public void FindSecondLargest()
        {
            BinarySearchTree tree = new BinarySearchTree();

            tree.Add(new Node {
                Value = 10
            });
            tree.Add(new Node {
                Value = 5
            });
            tree.Add(new Node {
                Value = 15
            });
            tree.Add(new Node {
                Value = 4
            });
            tree.Add(new Node {
                Value = 13
            });

            int result = tree.FindSecondLargest();

            Assert.AreEqual(13, result);
        }
コード例 #3
0
        public void ThrowsExceptionWhenRootNotSet()
        {
            BinarySearchTree tree = new BinarySearchTree();

            Assert.Throws(typeof(InvalidOperationException), () => tree.FindSecondLargest());
        }
コード例 #4
0
 public void ThrowsExceptionWhenRootNotSet()
 {
     BinarySearchTree tree = new BinarySearchTree();
     Assert.Throws(typeof(InvalidOperationException), () => tree.FindSecondLargest());
 }