By swapping we can adjust array only when the frequency of the element which occurs most is less than or equal to ( n + 1 ) / 2 .
if ( mx > Math . floor ( ( n + 1 ) / 2 ) ) document . write ( " " + " " ) ; else document . write ( " " ) ; }