Algorithms/Find maximum/Java findMax method 2
(Redirected from Find maximum/Java findMax method 2)
public int findMax(final int[] i_intaryTab) {
if ( i_intaryTab.length == 2 ) {
if ( i_intaryTab[0] > i_intaryTable[1] )
return i_intaryTab[0];
else
return i_intaryTab[1];
} // end if
final int[] p_intaryA = new int[i_intaryTab.length/2];
final int[] p_intaryB = new int[i_intaryTab.length/2];
for (int p_intI = 0; p_intI < (i_intaryTab.length / 2); p_intI++)
p_intaryA[p_intI] = i_intaryTab[p_intI];
int p_intK = 0;
for (int p_intJ = i_intaryTab.length/2; p_intJ < i_intaryTab.length; p_intJ++,p_intK++)
p_intaryB[p_intK] = i_intaryTab[p_intJ];
final o_intM = findMax(intaryA);
final o_intN = findMax(intaryB);
if ( o_intM > o_intN )
return o_intM;
else
return o_intN;
} // end method