# Assignment 1 : Binary Search

Hi Guys, I am getting a test case failed remark in both test cases 4 and 5. Please let me know if my test case is correct or not?

TEST CASE #4 rotated n-1 times
Input:
{‘nums’: [3, 5, 7, 1]}
Expected Output:
3
Actual Output:
3

TEST CASE #5 rotated n times
Input:
{‘nums’: [1, 3, 5, 7, 9]}
Expected Output:
0
Actual Output:
0

I don’t think they mean the test cases you have in the notebook (albeit, it won’t hurt to check if they really work) but the hidden test cases, known only to those who did this assignment.

Reset your notebook (clear all the outputs) and rerun all cells to make sure the tests really work. Perhaps your implementation changed and you didn’t rerun the tests.

2 Likes

Thanks, Sebgolos
But I want to know - are my test cases correct?
This means that is this the correct output when we rotate array n-1 times -
{‘nums’: [3, 5, 7, 1]}
Expected Output:
3
and the second case - when we rotate n times
{‘nums’: [1, 3, 5, 7, 9]}
Expected Output:
0

They are ok.

Had to make the post a bit longer because of answer length limit.

@anuragjoshi70 test cases we run are different than the ones provided in the assignment notebook.

Hi there,
I am facing this error as well. i did not figure out solution yet

Go through your code again, Probably you are doing something wrong in the implementation of the code.

If the middle number is the smallest number in the list e.g. [5,6,9,1,2,3,4], it will be less than the right most number in the list so according to our algorithm, the smallest number lies to the left of the current number and discards the current number and all the numbers to the right of it. So we will never be finding the smallest number as it was neglected in the first iteration itself. Is it not wrong?

in your example, the low=0 and high = len(nums)-1 = 6, so low+high // 2 = 3. This means the middle is at the index 3 with the element 1. Since as condition we have if value at [mid] less than [mid-1] which in this case it is. 1 < 9. We have found the answer which is [mid] so 3 also means 3 rotations which is the correct answer. If I understood your question.