title: Quicksort Algorithm (Recursion)
body: <p>I made a quicksort algorithm out of the visual presentation of the algorithm in youtube that I watched, but my recursion does not work at all. :(  If I commented out these 2 lines,</p>
  
  <pre><code>quicksort(array,0,start-1);
  quicksort(array,start+1,temp);
  </code></pre>
  
  <p>.. The program does not crash and the output becomes 2,1,3,5,4 which is partly correct.. But it crashes when it enters the recursion. After the whole while loop, the start becomes the same as the end.. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  
  void swap(int *a, int *b){
  
  int temp = *a;
  *a = *b;
  *b = temp;
  }
  
  void quicksort(int *array, int start, int end){
  
  int pivot = start;
  int temp = end;     
  while(start != end){
  
  if(pivot==start){
      if(array[pivot] &gt; array[end]){
      swap(&amp;array[end],&amp;array[pivot]);
      pivot = end;
      start++;
      }
      else
      end--;
  }
  else{
  if(array[pivot] &lt; array[start]){
      swap(&amp;array[start],&amp;array[pivot]);
      pivot = start;
      end--;
  }  
  else
  start++;   
  
  }               
  }
  
  quicksort(array,0,start-1);
  quicksort(array,start+1,temp);
  }
  
  
  
  
  main(){
  
  int x[5] = {3,1,5,2,4};
  int i;
  quicksort(x,0,4);
  for(i=0;i&lt;5;i++)
  printf("%d ", x[i]);
  getch();
  }
  </code></pre>