Re: permutation function problem
- From: tiger66 <liuallen1981@xxxxxxxxx>
- Date: Sat, 30 Jun 2007 00:25:08 -0700
On Jun 29, 7:19 pm, "Wade Ward" <inva...@xxxxxxxxxxxx> wrote:
"tiger66" <liuallen1...@xxxxxxxxx> wrote in messageokay, I will check out the books
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) {
int n= list.size();
int f= fac(n);
: List<T> perm= new ArrayList<T>();
but why doesn't my code work? I really want to find to solution to
this problem
Thanks
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;
}
Check out TAOCP from the library. What does the above do?
--
Wade Ward
.
- References:
- permutation function problem
- From: tiger66
- Re: permutation function problem
- From: Wade Ward
- permutation function problem
- Prev by Date: Re: Question of the software develpment cycle
- Next by Date: Re: Efficient Vector Comparison
- Previous by thread: Re: permutation function problem
- Next by thread: Help
- Index(es):
Relevant Pages
|