title: QuickSort doesn't work for large inputs
body: <p>Can anyone spot a problem with my quick sort implementation below? It seems to fail on arrays with more than 10 or so elements.</p>
  
  <pre><code>void swap(int *p1, int *p2)
  {
      int temp = *p1;
      *p1 = *p2;
      *p2 = temp;
  }
  
  void generateRandom(int arr[], int size)
  {
      srand(time(NULL));
      int i;
  
      for (i = 0; i &lt; size; i++)
      {
          arr[i] = rand() % 100;
      }
  }
  
  int partition(int arr[], int start, int end)
  {
      int i = start, j = end;
      int pivot = arr[start];
  
      for (;;)
      {
          for (; arr[i] &lt; pivot; i++);
          for (; arr[j] &gt; pivot; j--);
  
          if (i &lt; j)
          {
              swap(&amp;arr[i], &amp;arr[j]);
          }
          else
          {
              return j;
          }
      }
  }
  
  void quickSort(int arr[], int start, int end)
  {
      int part;
  
      if (start &lt; end)
      {
          part = partition(arr, start, end);
          quickSort(arr, start, part);
          quickSort(arr, part + 1, end);
      }
  }
  
  int main()
  {
      generateRandom(arr, 100);
      for (i = 0; i &lt; 100; i++)
      {
          printf("%d ", arr[i]);
      }
      printf("\n\n");
  
      quickSort(arr, 0, 99);
      for (i = 0; i &lt; 100; i++)
      {
          printf("%d ", arr[i]);
      }
      printf("\n\n");
  
      return 0;
  }
  </code></pre>