title: Big-O analysis of permutation algorithm
body: <pre><code>result = False
  def permute(a,l,r,b):
      global result
      if l==r:
          if a==b:
              result = True
      else:
          for i in range(l, r+1):
              a[l], a[i] = a[i], a[l]
              permute(a, l+1, r, b)
              a[l], a[i] = a[i], a[l]
  
  string1 = list("abc")
  string2 = list("ggg")
  permute(string1, 0, len(string1)-1, string2)
  </code></pre>
  
  <p>So basically I think that finding each permutation takes n^2 steps (times some constant) and to find all permutations should take n! steps. So does this make it O(n^2 * n!) ? and if so does the n! take over, making it just O(n!)?</p>
  
  <p>Thanks</p>
  
  <p>edit: this algorithm might seem weird for just finding permutations, and that is because i'm also using it to test for anagrams between the two strings. I just haven't renamed the method yet sorry</p>