title: How to find the time complexity of recursive selection sort?
body: <p>Hey guys i have a quiz tommorow i am facing some problems finding time complexity of recursive programm of selection sort can any one explain how is it n^2. And also one more question that some sorting algorithms loops have n/2 time complexity what is the meaning of /2 sorry for newbie question.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  // recursive function to perform selection sort on subarray arr[i..n-1]
  void selectionSort(int arr[], int i, int n)
  {
      // find the minimum element in the unsorted subarray[i..n-1]
      // and swap it with arr[i]
      int min = i;
      for (int j = i + 1; j &lt; n; j++)
      {
          // if arr[j] element is less, then it is the new minimum
          if (arr[j] &lt; arr[min])
              min = j;    // update index of min element
      }
  
      // swap the minimum element in subarray[i..n-1] with arr[i]
      swap(arr[min], arr[i]);
  
      if (i + 1 &lt; n)
          selectionSort(arr, i + 1, n);
  }
  </code></pre>