Displaying 1 result from an estimated 1 matches for "permutationsrecursive".
2008 Apr 06
3
Multiset Permutations
...mutations map to the same "bucket" in the hashtable, they
overwrite eachother to leave only unique permutations. Here's the algorithm
in Java:"
----------------------------- JAVA CODE --------------------------------
import java.util.*;
public class Test {
public static void PermutationsRecursive(char[] s, String p, Hashtable
perms){
for(int x=0; x<s.length; x++){
String np = new String(p);
char[] ns = new char[s.length-1];
int y = 0;
for(int z=0; z<s.length; z++){
if(z != x) ns[y++] = s[z];
}
np = np + s[x];
if(ns.length == 0) perms.put(np, new Boolean(true...