Exemple #1
0
        public void SearchForExistingElement()
        {
            var rotatedArray = new RotatedSortedArray();
            var nums         = new[] { 0, 0, 1, 1, 2, 0 };

            Assert.True(rotatedArray.Search(nums, 2));
        }
Exemple #2
0
        public void NonExistingElement()
        {
            var rotatedArray = new RotatedSortedArray();
            var nums         = new[] { 1, 2, 1 };

            Assert.False(rotatedArray.Search(nums, 0));
        }
Exemple #3
0
        public void TestSearch()
        {
            var rotatedArray = new RotatedSortedArray();
            var nums         = new[] { 0, 0, 1, 2, 2, 5, 6 };

            Assert.True(rotatedArray.Search(nums, 0));
            Assert.False(rotatedArray.Search(nums, 3));
        }
Exemple #4
0
        public void AllElementsAreSame()
        {
            var rotatedArray = new RotatedSortedArray();
            var nums         = new[] { 0, 0, 0, 0, 0 };

            Assert.True(rotatedArray.Search(nums, 0));

            Assert.False(rotatedArray.Search(nums, 1));
        }
Exemple #5
0
        public void MoreSearch()
        {
            var rotatedArray = new RotatedSortedArray();
            var nums         = new[] { 2, 5, 6, 0, 0, 1, 2 };

            Assert.True(rotatedArray.Search(nums, 0));

            Assert.False(rotatedArray.Search(nums, 3));
            Assert.False(rotatedArray.Search(nums, 4));
            Assert.True(rotatedArray.Search(nums, 6));
            Assert.True(rotatedArray.Search(nums, 1));
        }