Combinations and Permutations: UPDATE

This version brings updates to how it finds out all permutations, in the older version it used to search through the so far generated nodes backwards and pick a number that wasn’t used(dumb by all means, but got the job done). But when looked at it from a different perspective, why not have something like a dictionary? When used, mark it. But again there would be a problem of copying the whole array for the next call of the recursive method: it feels like we’d have to copy the whole thing but it doesn’t need to. What I did was to remove the change done after the recursive call, it was not a planned move but it should work. There was no reason not to. Done.

Download the source

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s