Permutation of string without recursion
<p>Here is the recursive code.<br />
Can you guys give inputs on how I can implement this using iterative method?</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PermAndComb
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "abcd";
            Permutation(s);
            Console.ReadKey();

        }

        public static void Permutation(string s)
        {
            int len = s.Length;
            char [] inStr  = s.ToCharArray();
            StringBuilder outStr = new StringBuilder();
            bool[] used = new bool[len];

            doPermute(inStr, outStr,used, len, 0);

        }

        public static void doPermute(char[] instr, StringBuilder outStr,bool [] used, int len, int level)
        {
            if (level == len)
            {
                Console.WriteLine(outStr.ToString());
                return;
            }

            for (int i = 0; i &lt; len; i++)
            {
                if (used[i]) continue;
                outStr.Append(instr[i]);
                used[i] = true;
                doPermute(instr, outStr, used, len, level + 1);
                used[i] = false;
                outStr.Length = outStr.Length - 1;

            }

        }
    }
}
</code></pre>
