0
My block/jump search is wrong.
It works if we search a number thats in the array. It also work if we search a number that is greater than the last element in the array. Now the problem is it produces no output if we search a number smaller than the greatest element. How do i let it work for any number smaller than the greatest element. https://code.sololearn.com/czS6I0gWD844/?ref=app
2 Answers
0
What exactly are you trying to do and what is jump for? Are you just looking to see if x is in the array?
0
your code produces output if it searches for a "a number smaller than the greatest " that is not in the array.
But it also produces incorrect outputs with "does not exist" even if they exist.
So add the return after the correct output,
and move the block with "doesn't exist" after for() block