Algorithms/Find maximum/java script method 3
Appearance
<script language="javascript">
function findMax(i_intAryTab,i_start,i_end) { if ( (i_end - i_start) == 1 ) { if ( i_intAryTab[i_end] > i_intAryTab[i_start] ) { return i_intAryTab[i_end]; } else { return i_intAryTab[i_start]; } // end if } // end if var intJ = (((i_end - i_start)+1)/2) - 1; var oMaxN = findMax(i_intAryTab,i_start,i_start+intJ); var oMaxM = findMax(i_intAryTab,i_start+intJ+1,i_end); if ( oMaxN > oMaxM ) { return oMaxN; } else { return oMaxM; } // end if } // end method function findMaxHandler(i_intAry) { return findMax(i_intAry,0,i_intAry.length - 1); } // end method var cc= new Array(3,6,1,9,1,1,1,12); var ii = findMaxHandler(cc); document.write(ii); </script>