Algorithms/Find maximum/Java findMax method 3

  public int findMaxHandler(final int[] i_intaryTab) {
     if ( i_intaryTab.length == 1 )
        return i_intaryTab[0];
     return findMax(i_intaryTab,0,i_intaryTab.length - 1);
  } // end method
  private int findMax(final int[] i_intaryTab,final int i_intStart,final int i_intEnd) {
     if ( (i_intEnd - i_intStart ) == 1 ) {
        if ( i_intaryTab[i_intEnd] > i_intaryTable[i_intStart] ) 
           return i_intaryTab[i_intEnd];
        else
           return i_intaryTab[i_intStart];
     } // end if 
     int intJ = (((i_intEnd - i_intStart)+1)/2) - 1;  
     final o_intM = findMax(i_intaryTab,i_intStart,i_intStart + intJ );
     final o_intN = findMax(i_intaryTab,i_intStart + intJ  +1,i_intEnd);
     if ( o_intM > o_intN )
        return o_intM;
     else
        return o_intN;
  } // end method
Last modified on 25 April 2009, at 03:15