mohamed.mostafa's blog

By mohamed.mostafa, 12 years ago, In English

public class Search {

static int []a ;
private static int tmax(int start, int end){
    if (end - start  == 0)
       return a[start];
    if (end - start== 1)
       return Math.max(a[start], a[start+1]);
    return Math.max(tmax(start, end/2), tmax(end/2+1, end));
}

public static void main(String[] args) {
    int []y = {10, 520, 300};
    a = y;
    System.out.println(tmax(0, a.length-1));
}

}

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it