title: Scan algorithm in Java
body: <p>So I have encountered some problem while doing Scan algorithm (operating system) in Java. I'd done the shortest seek time first algorithm to calculate for the disk optimization:</p>
  
  <pre><code>private int[] arrangeBySSTF(int current, int sequence[])
  {
      int n = sequence.length;
      int sstf[] = new int[n];
      for(int i =0; i &lt; n; i++){
          sstf[i] = sequence[i];
      }
  
      int ii = -1;
      for(int i =0; i&lt;n; i++)
      {
          int minimum = Integer.MAX_VALUE;
          ii = i;
          for(int j = i; j &lt; n; j++)
          {
              int distance = Math.abs(current - sstf[j]);
              if(distance &lt; minimum)
              {
                  ii = j;
                  minimum = distance;
              }
          }
          int tmp = sstf[i];
          sstf[i] = sstf[ii];
          sstf[ii] = tmp;
          current = sstf[i];
      }
      return sstf;
  }
  </code></pre>
  
  <p>However, I have no idea how to kick-start for the Scan algorithm. Does anybody can help?</p>
  
  <p>Thanks in advance.</p>