in reply to Re: permutation algorithm
in thread permutation algorithm

That's a memory hungry program! For 10 elements, you will create 1024 arrays, 20 elements give you 1048576 arrays, and 30 elements give you 1073741824 arrays.

The problem as given is in NP (and probably not in P), but that means it's in P-SPACE. Your solution however uses exponential memory.

Abigail

Replies are listed 'Best First'.
Re: Re: permutation algorithm
by fglock (Vicar) on Jul 12, 2002 at 14:45 UTC

    Mmmm, I was trying to solve the problem without a recursion.

    You are right. I am building the tree, instead of traversing it. We'd better use a recursion for this.