title: Counting the comparisons and swaps in a quick sort
body: <p>I am running a quick sort on 2000 integers read from a file but the number of comparisons and swaps i am getting seem high. Are my counters in the right place? or is something wrong with the sort?</p>
  
  <pre><code>public int partition(int array[], int low, int high) 
      { 
          int pivot = array[high];  
          int i = (low-1); 
          for (int j = low; j &lt; high; j++) 
          {
              compCounter++;
              if (array[j] &lt;= pivot) 
              { 
                  i++; 
                  int temp = array[i]; 
                  array[i] = array[j]; 
                  array[j] = temp; 
                  SwapCounter++;
              } 
          } 
  
          int temp = array[i+1]; 
          array[i+1] = array[high]; 
          array[high] = temp; 
          SwapCounter++;
  
          return i+1; 
      } 
  
      public void quickSort(int array[], int low, int high) 
      { 
          if (low &lt; high) 
          { 
              int pivotPoint = partition(array, low, high); 
              quickSort(array, low, pivotPoint-1); 
              quickSort(array, pivotPoint+1, high); 
          } 
      } 
  </code></pre>