Nice. > int third = len / div; > > // "medians" > int m1 = left + third; > int m2 = right - third; > > if (m1 <= left) { > m1 = left + 1; > } > if (m2 >= right) { > m2 = right - 1; > }
I'd suggest this instead: int third = len / div; third=third>0?third:1; // "medians" int m1 = left + third; int m2 = right - third;