PC Review


Reply
Thread Tools Rate Thread

algoritm special permutation

 
 
andrews
Guest
Posts: n/a
 
      17th Apr 2010
Hi,
I am looking at a algoritm for special permutation with integers like
f.e.
I start with 1,2,3,4,5

and I want the result

1 2 3 4 5
2 3 5 1 4
4 1 2 5 3
5 4 1 3 2
3 5 4 2 1

Some subset where al of the numbers are on different places

Thanks for any response


 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      17th Apr 2010
On 4/17/2010 3:46 AM, andrews wrote:
> Hi,
> I am looking at a algoritm for special permutation with integers like
> f.e.
> I start with 1,2,3,4,5
>
> and I want the result
>
> 1 2 3 4 5
> 2 3 5 1 4
> 4 1 2 5 3
> 5 4 1 3 2
> 3 5 4 2 1
>
> Some subset where al of the numbers are on different places
>
> Thanks for any response
>
>


The algorithm would be to take each of the items as the starting
element, and pass the remainders as a shorter list to find the
permutations of the shorter list. Take a smaller set, {1, 2, 3}.
Basically, you would keep the {1}, and pass {2, 3} to the permutations
to find the smaller lists permutations {2, 3} and {3, 2}. Now in the
caller you stick those two lists to the back end of {1}, so you have {1,
2, 3}, and {1, 3, 2}. Now you do the same with {2}, appending {1, 3}
and {3, 1}, and {3} appending {1, 2} and {2, 1}. You could implement
the algorithm using recursion, ending the recursion when the size of the
list passed in is one.

--
Mike
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need a algoritm to place user control Tony Johansson Microsoft C# .NET 10 12th Mar 2011 02:24 PM
permutation devildog8692 Microsoft Excel Programming 2 16th Jun 2009 05:44 AM
Re: algoritm question - how to fit? Jeroen Mostert Microsoft C# .NET 3 3rd Oct 2008 12:31 PM
Permutation =?Utf-8?B?bHVjb3R1c2xpbQ==?= Microsoft Dot NET 2 14th Aug 2005 06:16 PM
permutation user@domain.invalid Microsoft C# .NET 1 14th Apr 2004 12:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 AM.