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

10th Oct 2019, 8:13 PM
stephen haokip
stephen haokip - avatar
2 Réponses
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?
10th Oct 2019, 11:04 PM
Odyel
Odyel - avatar
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
11th Oct 2019, 11:13 AM
zemiak