If Max is a power of 2 and all array elements are equal
if ( isPower2 && CheckAllEqual ( arr , N ) ) { return parseInt ( ( Math . log ( Max ) / Math . log ( 2 ) ) ) ; } else { return parseInt ( Math . ceil ( Math . log ( Max ) / Math . log ( 2 ) ) ) + 1 ; } }