diff --git a/Searching/JumpSearch.cpp b/Searching/JumpSearch.cpp new file mode 100644 index 0000000..c85be72 --- /dev/null +++ b/Searching/JumpSearch.cpp @@ -0,0 +1,41 @@ +#include +#include + +using namespace std; +int jump_Search(int a[], int n, int item) { + int i = 0; + int m = sqrt(n); + + while(a[m] <= item && m < n) { + i = m; + m += sqrt(n); + if(m > n - 1) + return -1; + } + + for(int x = i; x> n; + int arr[n]; + cout << "\n Enter items: "; + + for(int i = 0; i< n; i++) { + cin >> arr[i]; + } + + cout << "\n Enter search key to be found in the array: "; + cin >> item; + loc = jump_Search(arr, n, item); + if(loc>=0) + cout << "\n Item found at location: " << loc; + else + cout << "\n Item is not found in the list."; +} \ No newline at end of file