protected int select(short[] S, int[] freq, int[] index, int start, int end, int k) {

    if (end == (start + 1)) {
      return start;
    } else {