title: Two questions about quicksort
body: <p>I have two questions when learning quicksort currently. The standard code is here(copy from my book):</p>
  
  <pre><code>void Quicksort(int a[], int low, int high){
      if(low&lt;high){
        int pivotpos=Patrition(a,low,high);
        Quicksort(a,low,pivotpos-1);
        Quicksort(a,pivotpos+1,high);
      }
  }
  int Patrition(int a[], int low, int high){
      int pivot=a[low];  //first elemnent as pivot
      while(low&lt;high){
          while(low&lt;high&amp;&amp;a[high]&gt;=pivot) --high;   //1
          a[low]=a[high];
          while(low&lt;high&amp;&amp;a[low]&lt;=pivot)  ++low;    //2
          a[high]=a[low];
     }
      a[low]=pivot;
      return low;     
  }
  </code></pre>
  
  <p>My questions are in the above code(marked 1 and 2):</p>
  
  <p>a. why the program cannot be performed(core dumped) when I type this in 1:
     <code>while(a[high]&gt;=pivot) --high</code> (similarly in 2). It seems that I have to add the <code>condition(low&lt;high)</code> in the second and third while loop or it said core dumped?</p>
  
  <p>b. another question is why there must be a <code>operator=</code> in second and third while loop. I am confused why it won't work when I type <code>while(low&lt;high&amp;&amp; a[high]&gt;pivot</code> (similarly in 2). If I do so, this program will keep looping and never goes to end.</p>
  
  <p>Thanks for your attention. Any suggestion will be highly appreciated.</p>