title: Quick Sort Recursion Stack Overflow
body: <p>I'm having an issue getting my program to compile due to a stack overflow.</p>
  <p>The issue lies on line 206 of the quicksort class.  I'm kind of stuck as to where to go next since this is my second ever course with Java.  Any and all help will be appreciated.  I'll post a snippet and a link to the GitHub repo as well.</p>
  <p><a href="https://github.com/das1tmane/Sort-Comparison" rel="nofollow noreferrer">https://github.com/das1tmane/Sort-Comparison</a></p>
  <p>Thanks.</p>
  <pre><code>public class QuickSort
      {
          /*
           * Select the first item of the partition as the pivot. Treat
           * partitions of size one and two as stopping cases.
           */
          public int firstPartition(int arr[], int low, int high)
              {
                  int pivot = arr[low];
                  int i = (high+1); // index of larger element
                  for (int j = high; j &gt; low; j--)
                      {
                          // If current element is smaller than or
                          // equal to pivot
                          if (arr[j] &gt;= pivot)
                              {
                                  i--;
  
                                  // swap arr[i] and arr[j]
                                  int temp = arr[i];
                                  arr[j] = temp;
                              }
                      }
  
                  // swap arr[i-1] and arr[low] (or *pivot*)
                  int temp = arr[i - 1];
                  arr[low] = temp;
  
                  return i-1;
              }
  
   public void sort(int arr[], int low, int high, int sortKind)
              {
                  // QuickSort type 1; Pivot at first element, 
                  if (low &lt; high &amp;&amp; sortKind == 0)
                      {
                          int pi = firstPartition(arr, low, high);
  
                          // Recursively sort elements before
                          // partition and after partition
                          sort(arr, low, pi - 1, 0);
                          sort(arr, pi + 1, low, 0);
                      }
                  // Quicksort type 2: stop at partitions of 100, then do
                  // insertion sort ```
  </code></pre>