Re: Computing subsets from a set? Programming Software Development by notagoodchoice …/timeit.html"]timeit[/URL]): [code=python] def subsets_i(s): subsets = [] n_elems = len(s) n_subsets = 2**len(s)… & 1): sub.append(s[j]) subsets.append(sub) return subsets [/code] The idea here is that a set… with n elements has n^2 subsets and that each subset #i with i = 0 … Computing subsets from a set? Programming Software Development by OLer94 …result' which would be a list of all computed subsets of 's'. I wrote the following code but…of errors. What am I missing here? [code] def subsets(s): result = [set()] for xi in s: newsubsets…=[] for subset in result: newsubsets.copy(subsets) newsubsets.add(xi) newsubsets.append(newsubsets) result.extend(… Re: Computing subsets from a set? Programming Software Development by jrcagle … by this line: [code="Python"] newsubsets.copy(subsets) [/code] Did you intend for newsubsets to become a… copy of subsets? If so, then you want [code="Python"…;] newsubsets = subsets[:] [/code] But I question the wisdom of clobbering newsubsets … Re: Computing subsets from a set? Programming Software Development by OLer94 …by this line: [code="Python"] newsubsets.copy(subsets) [/code] Did you intend for newsubsets to become a… copy of subsets? If so, then you want [code="Python"…;] newsubsets = subsets[:] [/code][/QUOTE] Yes, that way I can keep adding… Re: Computing subsets from a set? Programming Software Development by jrcagle … forget [] and [1,2,3], which are also subsets of b. P(b) = subsets(b) should have 2^len(b) elements. Here…, then P(b) = []. else: #b is not empty form all subsets x of size len(b)-1. Then P(b) = the… Re: Computing subsets from a set? Programming Software Development by jrcagle …thinking clearly at the moment: [code="Python"] def subsets(x): if x == []: return [[]] else: s = …in x: tmp = x[:] tmp.remove(elem) new_sub = subsets(tmp) for y in new_sub: # <-- can't …>>> s = [1,2,3] >>> subsets(s) [[1, 2, 3], [2, 3], [3], [], … Re: Computing subsets from a set? Programming Software Development by OLer94 …,2,3,3,3,4,4,7,5,8]) def subsets(s): result = [set()] for xi in s: finalsubsets=[] for subset…() newsubset.add(xi) finalsubsets.append(newsubset) return result print result subsets(p) [set([]), 1, 2, 3, 4, 5, 7, 8][/code… How to create subsets of a set...plz help..need it urgently Programming Software Development by anku83 … greater than given minimum support..If true then generate its subsets. If row 1 i.e 11110011 wight>min_sup then… generate subsets....if not then jump to next row here 1 represents… row one has 1,2,3,4,9,12 so subsets i need is {1,2,3},{1,3,4},{1… Re: Find all subsets of a given set - Optimization? Programming Software Development by ArkM … one long long int 64-bit word. That's ALL subsets generator ;) : [code=c++] long long unsigned n = (N < 1… elements } // long unsigned is a good type too (2^32 subsets) [/code] Supersonic code ;)... Re: Computing subsets from a set? Programming Software Development by notagoodchoice [QUOTE=notagoodchoice;871949] The idea here is that a set with n elements has n^2 subsets and that each subset #i with i = 0 .. (n^2 - 1) is described by the binary representation of the number i : [/QUOTE] .. oops, it's [B]2^n[/B] and not n^2. Find all subsets of a given set - Optimization? Programming Software Development by mrboolf … the original set and make it possible to generate all subsets. Right now I'm focusing on the "generate all… subsets" part. I've done a little searching and I … Re: Find all subsets of a given set - Optimization? Programming Software Development by ArkM …'s the answer to your doubts: you may enumerate all subsets for cardinality > 32 but you can't ;) do that… above... However if you need to fix/process large set subsets (not for absurd enumeration, of course), arbitrary size bitvectors are… Re: How to create subsets of a set...plz help..need it urgently Programming Software Development by anku83 … to check for each row: if(no_of_times_rows_repeated>minimum_support) generate subsets for items which has 1 uder it... example:if(no_of_times_rows_repeated… Re: Find all subsets of a given set - Optimization? Programming Software Development by ArkM 1. Try to profile subset generator without any printing. There are ~1 million subsets (2^20) for N==20. To print 1 million lines... The program PRINTS all the time. 2. NextSubset code is obviously wrong: [icode]while(!Bitmask[i]&&i>=0)[/icode] refers to Bitmask[-1] at the last loop. Present all class Subset definition. Re: Find all subsets of a given set - Optimization? Programming Software Development by mrboolf … was, given that my first bitmask-array method generated the subsets from { Whole Set } to { }, to use it in combination with… sum of subsets Programming Computer Science by nurav can anyone plz help me find the variable size solution for sum of subsets problem using backtracking Re: sum of subsets Programming Computer Science by nurav … we consider a set of numbers(weights)....the number of subsets whose sums are m have to be found out. For… writing all of the subsets of a set Programming Software Development by kshahnazari …,5} but it could be everything possible and there are subsets like b={1} c{1,2} d{1,2,4… Re: writing all of the subsets of a set Programming Software Development by kshahnazari … couted , but it still isnt the best way cause many subsets will be couted more than once , can Anyone help with… Re: writing all of the subsets of a set Programming Software Development by np complete @ kshahnazari First thing : Give n elements set, how will you find out total number of subsets in it ? Re: Computing subsets from a set? Programming Software Development by vegaseat Looks to me that you are using operations for sets like copy() and add() with lists. Re: Computing subsets from a set? Programming Software Development by jrcagle For what it's worth, my implemenation of this function used recursion. Re: Computing subsets from a set? Programming Software Development by woooee This thread is almost 2 years old. Re: How to create subsets of a set...plz help..need it urgently Programming Software Development by cgeier I'm confused by your explanation. How do you go from 11110011 to 1,2,3,4,9,12 ? How is "minimum support" defined? What kind of comparison do you want to do? Integer? Can you try to re-explain it. Also, what problems are you having? Re: Find all subsets of a given set - Optimization? Programming Software Development by mrboolf Thanks for your reply. 1. You're right, absolutely. Even with N = 30 it takes just ~36 seconds to complete the loop without any printing. :) I didn't know printing calls were [b]so[/b] expensive... 2. I apologize. Here's the full code (so far, some functions are still missing) corrected. [CODE=C++]#include <iostream> #ifndef H_SUBSET #… Re: Find all subsets of a given set - Optimization? Programming Software Development by ArkM Keep it simpler, swap subexpressions: [code=c++] while (i >= 0 && !Bitmask[i]) // that's all... [/code] I'll see your code later ;) Good luck! Re: Find all subsets of a given set - Optimization? Programming Software Development by mrboolf My ideas are bit(s) clearer now :P Now I should be able to work out the rest of the assignment. Thanks again for your time! Re: sum of subsets Programming Computer Science by Infarction Sure, but first you'll have to help yourself. We won't do it for you, so show what you've considered so far and why you think it's right or wrong and what you're stuck on. Re: writing all of the subsets of a set Programming Software Development by Ancient Dragon >can you please write a program for me Nice of you to ask, but No, we are not here to do your homework for you. Main Function Print out Programming Computer Science by Sherwin_4 … parent of i (path compression) if (subsets[i].parent != i) subsets[i].parent = find(subsets, subsets[i].parent); return subsets[i].parent; } /////////////////////////////////////////////////////////////////////// // A function that…