Пример #1
0
        public void BinarySearchMagicIndexRecursionTest()
        {
            Serarch target = new Serarch(); // TODO: Initialize to an appropriate value

            int[] data     = { 1, 2, 3, 3, 4, 6 };
            int   start    = 0;               // TODO: Initialize to an appropriate value
            int   end      = data.Length - 1; // TODO: Initialize to an appropriate value
            int   expected = 3;               // TODO: Initialize to an appropriate value
            int   actual;

            actual = target.BinarySearchMagicIndexRecursion(data, end, start);
            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void RotatedBinarySearchTest()
        {
            Serarch target = new Serarch(); // TODO: Initialize to an appropriate value

            int[] data     = { 15, 16, 19, 20, 25, 1, 3, 4, 5, 7, 10, 14 };
            int   x        = 26;
            int   left     = 0;
            int   right    = data.Length - 1;
            int   expected = -1;
            int   actual;

            actual = target.RotatedBinarySearch(data, x, left, right);
            Assert.AreEqual(expected, actual);
        }