code: public int get(int i) {
          if (i > Math.min(k, n) - 1) {
              throw new IllegalArgumentException("HeapSelect i is greater than the number of data received so far.");
          }
  
          if (i == k-1) {
              return heap[0];
          }
          
          if (!sorted) {
              sort(heap, Math.min(k,n));
              sorted = true;
          }
  
          return heap[k-1-i];
      }
docs: Returns the i-<i>th</i> smallest value seen so far. i = 0 returns the smallest
  value seen, i = 1 the second largest, ..., i = k-1 the last position
  tracked. Also, i must be less than the number of previous assimilated.