diff --git a/Jump Search/jump_search.cpp b/Jump Search/jump_search.cpp new file mode 100644 index 0000000..d9abf2a --- /dev/null +++ b/Jump Search/jump_search.cpp @@ -0,0 +1,33 @@ +#include +#include +using namespace std; +int main(){ + int n; + cout<<"Enter the number of elements: "; + cin>>n; + cout<<"Enter the elements in the sorted order: "; + int a[n]; + for(int i=0;i>a[i]; + } + int d; + cout<<"Enter the element to search: "; + cin>>d; + int x,i; + cout<<"Enter the skip count: (Preferred: "<>x; + for(i=0;id){ + break; + } + } + for(int t=i;t Jump Search +Jump Search is a faster algorithm than Binary search. It is just a modified form of binary search where a small range of numbers are found in which the desired number lies by jumping some indexes in between. Then the desired index is found out by using linear search in that particular small range. The number of indices jumped is preferred to be the square root of the length of array.
+Time Complexity: O(n/m + (m-1)) where n is the length of array and m is the jump size.