@Override
  public int select(short[] S, int[] freq, int start, int end, int k) {
    // Non-destructive selection
    short[] copyS = Arrays.copyOf(S, S.length);
    int[] index = new int[S.length];