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);
        }
        public void AddingNodes()
        {
            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 });

            Assert.AreEqual(10, tree.Root.Value);
            Assert.AreEqual(5, tree.Root.Right.Value);
            Assert.AreEqual(15, tree.Root.Left.Value);
            Assert.AreEqual(4, tree.Root.Right.Right.Value);
            Assert.AreEqual(13, tree.Root.Left.Right.Value);
        }
        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);
        }
        public void ThrowsNullArgumentExceptionWhenNullNodePassed()
        {
            BinarySearchTree tree = new BinarySearchTree();

            Assert.Throws(typeof(ArgumentNullException), () => tree.Add(null));
        }
 public void ThrowsNullArgumentExceptionWhenNullNodePassed()
 {
     BinarySearchTree tree = new BinarySearchTree();
     Assert.Throws(typeof(ArgumentNullException), () => tree.Add(null));
 }