Thread: Permutation and Combination

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    Unhappy Permutation and Combination

    Hi please help me.. I am writing a larger program which requires the below modulde..


    I want the program to take an multidimensional integer array os size n x n1. Which contain only the numbers 1, 0 and -1.
    for example..

    1 0 0 0
    or
    -1 0 -1
    or
    0 0 0 0 1 1 -1 0

    So i want the program to alter the 0's to both 1 and -1 and get all possible combinations. But it should not alter the already present -1 and 1. it should just aler the 0's.

    Help Me please...

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You could count the number of zeros you have (and the posistions they occupy). Create a temporary array the size of the number of zeros, and use an algorithm to generate the possible combinations of this temporary array. Each time a combination is generated put it back to the into the original array.

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    That cannot be done since the number of zeros can be at some ties upto 300 to 600. So writing such an algorithm based on the position will be really big...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Permutation?
    By koolguysj in forum C Programming
    Replies: 1
    Last Post: 04-02-2005, 09:24 AM
  2. Permutation Calculation
    By Eric Hansen in forum C++ Programming
    Replies: 21
    Last Post: 06-11-2003, 04:03 PM
  3. permutation
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 09-01-2001, 04:13 AM