Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Algorithm for permutations

  1. #1
    Member Scorks's Avatar
    Join Date
    Jan 2013
    Posts
    56
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Algorithm for permutations

    Consider the problem of generating all permutations of length k of a set of cardinality n, where n is a non-negative integer number and k < (or) = n is a non negative integer number.

    So far, I have the method:

    methodB (int[] a) {
    if |a| = 1   return {a}
    else
    sol = { }
    for every x in a {
    sub = a – {x}
    block = method (sub)
    for each element in block, insert x in front of it
    }
    sol = sol U block
    }

    But I know this doesn't really solve the problem, as I need to make it for a predefined space of K. Anyone able to help me out?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Algorithm for permutations

    I'm a bit lost in the math jargon and don't want to study up on it. Can you put the assignment into plain English?

  3. #3
    Member Scorks's Avatar
    Join Date
    Jan 2013
    Posts
    56
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Algorithm for permutations

    I got it pretty soon afterwards. Thanks anyways.

Similar Threads

  1. Permutations using Arraylist
    By steel55677 in forum Collections and Generics
    Replies: 1
    Last Post: March 15th, 2013, 03:12 AM
  2. Permutations using Arraylist
    By steel55677 in forum Collections and Generics
    Replies: 1
    Last Post: March 14th, 2013, 06:58 PM
  3. Help generating random permutations from array list
    By mactank13 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: December 2nd, 2012, 09:04 PM
  4. permutations of a string using iteration
    By ueg1990 in forum Java Theory & Questions
    Replies: 11
    Last Post: August 11th, 2012, 03:23 PM
  5. Finding all Permutations that add up to a number.
    By godsfearme in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 28th, 2010, 03:54 PM

Tags for this Thread