Re: permutation function problem
- From: "Wade Ward" <invalid@xxxxxxxxxxxx>
- Date: Fri, 29 Jun 2007 21:19:53 -0400
"tiger66" <liuallen1981@xxxxxxxxx> wrote in message
news:1183144766.352345.115410@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All
I am trying to create a permutation function. I found the
implementation online, but the implementation uses for() loop in the
main() and it has the List as a parameter. All I am trying to do is to
modify the implementation, so that all the loops are in the function
and the parameter is a char array instead of a list.
public static <T> List<T> permute(List<T> list, int r) {Check out TAOCP from the library. What does the above do?
int n= list.size();
int f= fac(n);
: List<T> perm= new ArrayList<T>();
list= new ArrayList<T>(list);
for (list= new ArrayList<T>(list); n > 0; n--, r%= f) {
f/= n;
perm.add(list.remove(r/f));
}
return perm;
}
--
Wade Ward
.
- Follow-Ups:
- Re: permutation function problem
- From: tiger66
- Re: permutation function problem
- References:
- permutation function problem
- From: tiger66
- permutation function problem
- Prev by Date: Re: Efficient Vector Comparison
- Next by Date: Re: Question of the software develpment cycle
- Previous by thread: permutation function problem
- Next by thread: Re: permutation function problem
- Index(es):
Relevant Pages
|