Guys!! any one can help me in recursive permutation of integer array!!

this is the description of my problem:
We are supposed to develop a recursive method with the following header:
public static boolean nextPermutation(int[] array)
The method receives an integer array parameter which is a permutation of integers 1, 2, �, n. If there is �next� permutation to the permutation represented by the array, then the method returns true and the array is changed so that it represents the �next� permutation. If there is no �next� permutation, the method returns false and does not change the array.
Here is a verbal description of the recursive algorithm you need to implement:
1. The first permutation is the permutation represented by the
sequence (1, 2, �, n).
2. The last permutation is the permutation represented by the
sequence (n, �, 2, 1).
3. If is an arbitrary permutation, then the �next� permutation is
produced by the following procedure:
(i) If the maximal element of the array (which is n) is not in the first
position of the array, say , where , then just swap and . This
will give you the �next� permutation in this case.
(ii) If the maximal element of the array is in the first position, so ,
then to find the �next� permutation to the permutation , first find
the �next� permutation to , and then add to the end of thus
obtained array of (n-1) elements.
(iii) Consecutively applying this algorithm to permutations starting
from (1, 2, �, n), you will eventually list all possible
permutations. The last one will be (n, �, 2, 1).
For example, below is the sequence of permutations for n = 3 , listed by the described algorithm:
(0 1 2) ; (0 2 1) ; (2 0 1) ; (1 0 2) ; (1 2 0) ; (2 1 0)
if any one can help me then please help me!! i am stucked at this position to find permutation of the integer array.
thanks,

Sure. Why don't you post the code you already have done, and maybe
someone here can help you with it.

Similar Messages

Maybe you are looking for

  • What is the major updates in ios 5.1

    i just update to ios 5.1 for my 3gs i didnt find any new updates unless the camera icon in lock screen what els is goodz ??

  • Since iOS 8 my purchases disappeared and I cannot re-download them!

    Since iOS 8 my purchases disappeared and I cannot re-download them!  I have tried going to purchased items and hitting the download from icloud icon.  It just says downloading, then goes back to the download icon. I have tried syncing from my Mac - s

  • Idoc issue - canbe fixed with enhancement?

    Hi idoc Gurus, I have issue related to idoc. We have extended the DEBMAS with one custom segment(Z1KNA13). Custom segment(Z1KNA13) has three fields. one of the field is to store customer's second address line(cust_address2). When someone changes the

  • Need help - Date format in es Tag / LoadedData

    hi, I have one Date attribute called 'EXPIRATION_DATE' in DOCUMENT table. I mapped this column entry in 'application-config.xml' as jdbc.column.EXPIRATION_DATE=ExpirationDate; And when I am trying to get this value in JSP,within '<es:forEachInArray>'

  • GST Malaysia reverse charge through Deferred tax

    Dear Community Members, rather than following SAP's suggestion to implement (at least) the four notes 1979386, 2000583, 2011533 and 2062785, we decided to go for a custom development to post the reverse charges, I mentioned that in an earlier blog en