code: public static int median(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int begin, int end) {
      final int length = end - begin;
      assert (length > 0);
      // Integer division is "floor" since we are non-negative.
      final int left = begin + ((length - 1) >> 1);
      quickSelect(data, comparator, begin, end, left);
      return left;
    }
docs: Compute the median of an array efficiently using the QuickSelect method.
  
  On an odd length, it will return the lower element.
  
  Note: the array is <b>modified</b> by this.
  
  @param data Data to process
  @param comparator Comparator to use
  @param begin Begin of valid values
  @param end End of valid values (exclusive!)
  @return Median position