Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a problem when using approri algorithm

the problem is:

have a number of item set={1,2,3,4,5}

i want put it in listbox but by this way:

1,2
1,3
1,4
1,5
2,3
2,4
2,5
3,4
3,5
4,5
1,2,3
1,2,4
1,2,5
1,3,4
1,3,5
1,4,5
2,3,4
2,3,5
3,4,5
1,2,3,4
1,2,3,5
2,3,4,5
1,2,3,4,5
------------

There is any one can help me to found a solution to this Problem

may solved by variation or combination...plz Help
Posted
Comments
Sergey Alexandrovich Kryukov 13-Apr-11 17:40pm    
The rule for n-the list item, please, or recursive. A definition.
--SA
Sandeep Mewara 14-Apr-11 1:34am    
Any effort?

1 solution

What you showed in your question seems to be what is defined as a "Power Set"[^] in algebra. A bit of googling gave me this algorithmic definition (danger it's abstract!): http://stackoverflow.com/questions/2779094/what-algorithm-can-calculate-the-power-set-of-a-given-set[^] and finally here you'll find how it is done in SQL: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=144749[^] with one restriction that it does not work for any number of elements in the starting set.

Now googling that wasn't so hard. Hard was finding the right term "Power Set" as it is known as "Potenzmenge" in my mother tongue.

Hope that helps you along!

Cheer,

-MRB
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900