kavi wrote:
> Hi Team,
>
> Could anyone please give me the logic for the following
>
> 1. I have an array of values with VM seperation.The array can have any
> number of values.
>
> Example ---- ARRAY = 'A':VM:'B':VM:'C'
>
> 2. If the count is 3, i want 3!(factorial) combinations to be
> displayed like
>
> ABC
> ACB
> BCA
> BAC
> CAB
> CBA
>
> Likewise, if the count is 4, then there should be 4! combinations (ie
> 24 combinations).
>
> The count should be n numbers.(Generic and not a specific value.)
>
> I need a logic to implement this. Please help me
>   
HI,

Please do not post the same question 5 times as you might get 5 
different answers, which you will anyway. Please read the posting 
guidelines where you will find that this is a moderated group and you 
must wait for your post to be approved.

This is a standard problem in combinatorics, and I should caution you 
about the story of the man who wanted to be paid with coins doubled on 
chess-board squares and other old saws, but whatever ;-), I will just 
point out that past about 9! you are going to be spending a long time 
and a fair bit of memory doing this in BASIC :-)

However, there are some good recursive algorithms that will run in 
linear time. Choose one that generates the permutations in the order 
that suits you best. Here http://www.ddj.com/architect/201200326 they 
are listed in Pascal which should be easily convertible to jBC. If you 
find Java easier to read and just need any algorithm, then this one is 
good: http://www.merriampark.com/perm.htm

Use Google and look for permutation algorithms - they have been around 
since the dawn of time and computer versions since the dawn of computing.

Jim



--~--~---------~--~----~------------~-------~--~----~
Please read the posting guidelines at: 
http://groups.google.com/group/jBASE/web/Posting%20Guidelines

IMPORTANT: Type T24: at the start of the subject line for questions specific to 
Globus/T24

To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to