title: complexity of recursive string permutation function
body: <p>From: <a href="https://stackoverflow.com/questions/1995328/are-there-any-better-methods-to-do-permutation-of-string">Are there any better methods to do permutation of string?</a></p>
  
  <p>what is the complexity of this function???</p>
  
  <pre><code>void permute(string elems, int mid, int end)
  {
      static int count;
      if (mid == end) {
          cout &lt;&lt; ++count &lt;&lt; " : " &lt;&lt; elems &lt;&lt; endl;
          return ;
      }
      else {
      for (int i = mid; i &lt;= end; i++) {
              swap(elems, mid, i);
              permute(elems, mid + 1, end);
              swap(elems, mid, i);
          }
      }
  }
  </code></pre>