Interview Question

Software Engineer Interview

was asked about perm gen in java.

Answer

Interview Answer

1 Answer

0

public class Permutation
{
    stringBuilder output;
    String input;
    boolean used[];

    public Permutation(String in)
    {
        this.input = in;
        output = new StringBuilder();
        used = new Booolean[n];
    }

    public void Permute(String in)
    {
        if(in.length() == output.length())
        {
            print(output.toString());
        }
        for(int i=0;i<in.length; i++)
        {
            output.append(input.charAt(i));
            used[i] = true;
            permute(in.substring(i));
            used[i] = false;
            output.setLength(output.length() - 1);
        }
    }
}

Zahid on Nov 29, 2013

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up