jump search algorithm

Posted by davit-datuashvili on Stack Overflow See other posts from Stack Overflow or by davit-datuashvili
Published on 2010-05-21T13:18:33Z Indexed on 2010/05/21 13:20 UTC
Read the original article Hit count: 470

Filed under:

i am doing jump search algorithm but it show me that element is not in array while it is here is code import java.math.*; public class jamp { public static int min(int a,int b){ return a

}

public static void main(String[]args){

int a[]=new int[]{3,7,9,12,14,15,16,17,18}; int l=14; System.out.println(jumpsearch(a,a.length,l));

} public static int jumpsearch(int a[],int n, int l ){

  int t=0;

int b=(int)Math.sqrt(n); while (a[min(b,n)-1]=n) return -1 ; } while (a[t] return -1 ; if ( a[t]==l) { return t; }

}

return -1;

} }

please help

© Stack Overflow or respective owner

Related posts about algorithm