n different objects in p containers

Discussion in 'C Programming' started by mghorba, Oct 28, 2014.

?

n different objects in p containers

  1. pseudo code

    0 vote(s)
    0.0%
  2. code

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. mghorba

    mghorba

    Joined:
    Oct 28, 2014
    Messages:
    2
    Likes Received:
    0
    I am trying to write a code that lists all possible assignments of say n objects in p containers.

    For instance, if N={a,b} is the containers set and S={1,2} is the objects, then I want to have:

    { ( {1,2} , { } ) ; ( {1} , {2} ) ; ( {2} , {1} ) ; ( { } , {1,2} ) } where the tuple elements are respectively assignments to objects a and b from N.

    This grows rapidly in fact for N containers and S objects, there are N^S possibilities which I want the program to list.

    How you ever encountered any code, pseudo code, or algorithm that would list all the possibilities?

    Thanks a lot.
     
    mghorba, Oct 28, 2014
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.