title: Quicksort. How to choose pivot element?
body: <p>I read about quicksort algorithm and I don't understand how to choose pivot element. From tutorials I get example code of quciksort: </p>
  
  <pre><code>public void quicksort(int[] A, int left, int right) {
      int pivot = A[left + (right - left) / 2];
      int i = left;
      int j = right;
      while (i &lt;= j) {
          while (A[i] &lt; pivot) {
              i++;
          }
          while (A[j] &gt; pivot) {
              j--;
          }
          if (i &lt;= j) {
              exchange(i, j);
              i++;
              j--;
          }
      }
  
      if(left &lt; j)
          quicksort(A,left,j);
      if(i &lt; right)
          quicksort(A,i,right);
  }
  </code></pre>
  
  <p>But why we choose pivot using this  <code>A[left + (right - left) / 2];</code>?</p>
  
  <p>Why not <code>A[(right - left) / 2]</code></p>