pastebin code(C++): https://pastebin.com/tTpJ4Ni0 #include <iostream> #include <cmath> using namespace std; int JumpSearch(int x); int BinarySearch(int x, int left, int right); int V[] = {1,2,3,4,5,6,7,8,9,10}; int main() { cout << JumpSearch(8); return 0; } int JumpSearch(int x) { int left = 0; int right = sqrt(10); while (left < right){ if (V[right] == x) return right; if (V[right] > x) return BinarySearch(x,left,right); if (V[right] < x) left = right; right = right * 2; } } int BinarySearch(int x, int left, int right) { if (left < right){ int mid = (left + right) /2; if (V[mid] == x) return mid; if (V[mid] >x) right = mid - 1; if (V[mid] < x) left = mid +1; } return -1; } i always get -1 as a result, no matter what number i put in to search, some help, im stucked :/

4/1/2020 10:30:41 AM

Lyrdum2 Answers

New Answer
Welcome to SoloLearn forum!
SoloLearn codeplayground needs a serious update!
Could I ask you?
Is learning from sololearn enough???
Help in XYZ problem in python?
Is knowing Python necessary for learning R ?
Can article and section be nested inside each other? How do they
I need to learn HTML but I don't know how?
How to create a number list tag
What is the most simple way to convert a string into an arrr

Learn Playing. Play Learning

SoloLearn Inc.

4 Embarcadero Center, Suite 1479

San Francisco, CA 94111

© 2020 SoloLearn, Inc. All rights reserved.

Send us a message